Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 29th, 2008, 05:49 AM
Registered User
 
Join Date: Oct 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default HELP ME! Project with event procedures

I have a project with a form, in which I need the following procedure: as I finish filling the first field (control) in the form,, named "ID Oper B", it gets desabled so that the next person to use this form does not see the information that has been entered. For that porpuse I created the following event procedure:

Private Sub ID_Oper_B_LostFocus()
        Me!IDOperB.Enabled = False
End Sub

I get the error message "Run time error. Object doesn't support this property or method"

I also need the next field ("Operação") to be enabled as I fill in the previous field (ID Oper B) with a certain value, "joaquim". Fo that porpuse i created the following event:

Private Sub Operação_BeforeUpdate(Cancel As Integer)
        If Me!IDOperB = "joaquim" Then
        Me!Operação.Enabled = True
        Me!Operação.Locked = False
    Else
        Me!Operação.Enabled = False
        Me!Operação.Locked = True
        End If
End Sub

When i move out of the "ID Oper B" control, the next control does not get enabled

What am i doing wrong? Can anybody help me?

I would appreciate it!

Luís

 
Old October 29th, 2008, 07:29 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   On the first issue, I think the problem is that you are trying to disable the control on an event for the control, which you can't do. So what I would do is something like:

Private Sub ID_Oper_B_LostFocus()
        Me.AnotherControl.SetFocus = True 'you may not need = True
        'Me.AnotherControl.SetFocus
End Sub

(alternatively, you can set this in the tab order for the form.)

then:

Private Sub AnotherControl_GotFocus()
        Me.ID_Oper_B.Enabled = False
End Sub

On the second issue, BeforeUpdate is not going to fire until the record is saved, so moving to the next control should not fire the event. In that case you could do this:

Private Sub ID_Oper_B_LostFocus()

If Me!IDOperB = "joaquim" Then
   Me!Operação.Enabled = True
   Me!Operação.Locked = False
   Me!Operação.SetFocus = True 'or
   'Me!Operação.SetFocus
Else
   Me!Operação.Enabled = False
   Me!Operação.Locked = True
End If

End Sub

Disabling the control will take if it out of the tab order.

Did any of that help?



mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access project using event procedures luissilva755 Access VBA 1 October 29th, 2008 07:33 AM
Event - Sender & Event args dash dev C# 2005 9 December 9th, 2007 07:24 AM
Favorites Project - Right-Click Event Nat4 BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 5 October 24th, 2007 09:49 AM
Website project vs Web Application Project... thenoseknows ASP.NET 2.0 Professional 0 January 14th, 2007 09:47 PM
Event procedures Primary Form ru1 Access 8 March 7th, 2005 03:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.