I need to change the Enabled property after changing records

dannydm

New member
Local time
Today, 05:46
Joined
Nov 23, 2005
Messages
7
Hi Guys,

i have a problem i hope some one can help me with.

i have a form with a sub form on it, and i want to disable everything until the user clicks a 'edit' button to allow the information to be changed.

i am just testing it at the moment, so i set one text box's enabled property to false. then i added a button with an on click event with the following code:

Me!userid.Enabled = True

when i start the form, the userid box is disabled and when i click on the edit button, it enables it fine.

however, when i change to the next record, the userid box remains enabled. i cant find where to put the code to set it back to false everytime i change the record.

i should also let you know i am a beginner, so please be gentle!
 
Use the Form_Current event:

Code:
Private Sub Form_Current()
    Me.UserID.Enabled = Me.NewRecord
    Me.UserID.Locked = Not Me.NewRecord
End Sub

I would, however, suggest you change the textbox's name to txtUserID. This identifies it as a textbox and, even better, reduces confusion over whether you are referring to the textbox object or the underlying field - they are two separate entitites.
 
ok thanks that worked out great!
 

Users who are viewing this thread

Back
Top Bottom