Using a checkbox to disable/enable fields

Pickles

New member
Local time
Today, 15:12
Joined
Feb 12, 2007
Messages
8
I want to enable/disable certain fields when a checkbox is ticked. I have put in the following coding in the "After Update" bit but it doesn't seem to work. Am I putting it in the wrong place or is just because my coding just really bad?

If Me.Member = True Then
Me.Member_ID.Enabled = True
Me.tbl_Appointment_First_Name.Enabled = False
Me.tbl_Appointment_Surname.Enabled = False
Me.tbl_Appointment_Contact_Number.Enabled = False
Else
Me.Member_ID.Enabled = False
Me.tbl_Customer_First_Name.Enabled = False
Me.tbl_Customer_Surname.Enabled = False
Me.tbl_Customer_Contact_Number.Enabled = False
Me.tbl_Appointment_First_Name.Enabled = True
Me.tbl_Appointment_Surname.Enabled = True
Me.tbl_Appointment_Contact_Number.Enabled = True
End If


Any help would be much appreciated, thanks!!
 
Last edited:
Try putting it in the Click event of the CheckBox
 
It says that it can't find the macro "If Me"
 
On the event tab of the properties sheet for the control, press the "..." button and select Code Builder. Then put your code in there.
 
That's what I've been doing but it still doesn't work.
 
Does the space next to the ClickEvent have [Event Procedure] in it? Did you compile? The error you describe is one you would get if you tried to just paste code directly into that spot that should say [Event Procedure]. Maybe you could post the entire Sub from Private Sub to End Sub and we can look at it.
 
This is when I enter it into OnClick:

Private Sub Member_Click()
If Me.Member = True Then
Me.Member_ID.Enabled = True
Me.tbl_Appointment_First_Name.Enabled = False
Me.tbl_Appointment_Surname.Enabled = False
Me.tbl_Appointment_Contact_Number.Enabled = False
Else
Me.Member_ID.Enabled = False
Me.tbl_Customer_First_Name.Enabled = False
Me.tbl_Customer_Surname.Enabled = False
Me.tbl_Customer_Contact_Number.Enabled = False
Me.tbl_Appointment_First_Name.Enabled = True
Me.tbl_Appointment_Surname.Enabled = True
Me.tbl_Appointment_Contact_Number.Enabled = True
End If
End Sub
 
The references seem fine; I've followed the quick solution (don't really understand anything else :confused: )

But when I try to use the checkbox, I get the message:

"Compile Error: Method or data member not found"

It takes me back to VB and highlights

Private Sub Member_Click()

I've still got the same code as I posted before.
 
Can you try a compact and repair Tools>Database Utilities and see what happens? Maybe you could post your zipped up db with any sensitive data removed and we can look at it. Something is fishy and I can't see it from here.
 
While you are looking at the code did you go to Debug>Compile?
 
After trying the compact and repair, it does nothing other than make the database smaller. I tried the checkbox again and it came up with the same message.

Going to Debug>Compile makes the same "Compile Error" message appear.
 
Last edited:
Good morning Pickles!
I can not find any controls named tbl_Customer_First_Name or tbl_Customer_Surname on your frm_Appointment. When I comment out those two lines it compiles.
 
Afternoon RuralGuy,

Thanks for the help, I see it now!

*feels stupid*
 
Glad I could help Pickles. Afternoon huh? Are you across the "pond"?
 
Yep, I live in the UK; and would I be right in guessing you're in Colorado?
 
OK, who's giving away my well kept secrets? ;) Surrounded by trees, wildlife and snow at the moment. I love it. Later!
 

Users who are viewing this thread

Back
Top Bottom