SetFocus

EndersG

Registered User.
Local time
Today, 16:59
Joined
Feb 18, 2000
Messages
84
I was struggling with a function using the Form Current event.

I tried to enable and disable a field (field1) based on the value of a textbox (textbox1). If textbox1 equals Y then field1 was enabled and if textbox1 was equal to N then Field1 was disabled for every new record you select. So I went into the Form_Current() module and proceeded to write (using the Build... feature, mind you) the following code:

Private Sub Form_Current()
If Me![textbox1].text = "Y" Then
Me![subForm].[Form]![field1].enable = true
Else
Me![subForm].[Form]![field1].enable = false
End If
End sub

Needless to say, with this approach, I got debugging errors telling me I had to use SetFocus on the control and whatnot. I tried everything. It wasn't until after I was desperate that I deleted the leading Me! identifier and trailing .Text property that I finally got it to work.

Private Sub Form_Current()
If textbox1 = "Y" then
[subForm].[Form]![field1].enable = true
Else
[subForm].[Form]![field1].enable = false
End If
End sub

And I didn't have to use SetFocus. Why wouldn't it work with the more descriptive identifiers? Please advise what I did wrong.
 

Users who are viewing this thread

Back
Top Bottom