Field being enabled based on checkbox

miacino

Registered User.
Local time
Today, 12:41
Joined
Jun 5, 2007
Messages
106
I'm trying to code so that a textbox field is only enabled IF a certain checkbox is checked.

Using this code:

Private Sub checkbox_AfterUpdate()

If Me.[checkbox] = True Then
Me.[textbox].Enabled = True
Else
Me.[textbox].Enabled = False
End If
End Sub

When I click the checkbox - I get "runtime error 438 - object doesn't support this property or method".

What am I missing?
 
you appear to be using dummy names, so difficult to determine the exact problem, but the error message implies that textbox is not a textbox

you can also simplify your code to

Code:
Me.[textbox].Enabled = Me.[checkbox]

or you can use conditional formatting so no code required
 
Yes, was using dummy names for ease of understanding. Maybe my field names are, in fact, the error? "Study10-055" is the field name for the yes/no checkbox.
"StudyID_10055" is the name of the text field (for the study ID).

Private Sub Study10_055_AfterUpdate()
If Me.[study10-055] = True Then
Me.[studyID_10055].Enabled = True
Else
Me.[studyID_10055].Enabled = False
End If
End Sub
 
names can be a problem, but the error message is not saying it can't find the object, but the object is the wrong type
 
Problem solved. Apparently the default for the checkbox field was at YES. The default needs to be NO.
 

Users who are viewing this thread

Back
Top Bottom