Checkbox Macro for other control visibility

demicay2669

Registered User.
Local time
Today, 08:10
Joined
Aug 22, 2013
Messages
39
I'm trying to setup a Macro for two Checkboxes in my Web Database, so that when one of them is checked two other fields become come visible for input.
I have ckbCustomer and ckbSupplier. I want ckbCustomer to make text box CustName and CustID visible and ckbSupplier to make text box SupplierName and SupplierID visible when checked.

I found this code thanks to BaldyWeb.com
Code:
[FONT=Arial]  
    If Me.ControlName = "Whatever" Then
        Me.OtherControlName.Visible = True
    Else
        Me.OtherControlName.Visible = False
    End If
[/FONT]

This is the way I put the above code into my macro.
Code:
If [Me].[ckbCustomer]=True
    SetProperty CustName.Visible=True
Else
    CustName.Visible=False
End IF

I get an error MS Access cannot find the Name 'Me' you entered in the expression. And if I take the 'Me' off it says the same thing but just 'ckbCustomer' instead of 'Me'. My database is attached.
I'm not sure what I have done wrong. Any help would be much appreciated.
 

Attachments

You cannot use Me. in a Macro. It should be used in VBA. Use the Expression builder in the Macro to get the Control name properly.
 
Nevermind on the error it doesn't seem to affect the outcome eitherway. The macro still worked just fine. Even though it says the same thing when I run the Macro with 'ckbCustomer'.
But I'm also trying to make it work for two fields to become visible once its checked. 'CustName' and 'CustID'. I tried just putting 'and' in between them but that didnt work, gives me an error of "The control name 'CustName and CustID is misspelled or refers to a control that doesn't exist.
 
Last edited:
The Macro still worked when I checked the box with just 'ckbCustomer', it just gives me the error if I click run while in the Macro Builder.
But I'm also trying to make it work for two fields to become visible once its checked. 'CustName' and 'CustID'. I tried just putting 'and' in between them but that didnt work, it gives me an error of "The control name 'CustName and CustID' is misspelled or refers to a control that doesn't exist.
 
It would make your life so much easier, if you just worked on VBA.

But as the Error describes, "The control name 'CustName and CustID' is misspelled or refers to a control that doesn't exist." That is exactly what is happening. Again I say this, use the Expression builder. Typing by hand will always cause trouble.
 
Its for a Web Database. I pushed the ... button on the AfterUpdate and it takes me to an Embedded Macro. But I figured out what I needed.
Thank you.

I attached the Macro.
 

Attachments

  • macroCode.PNG
    macroCode.PNG
    14.7 KB · Views: 328
How do I set the 'CustName' 'CustID' 'SupplierName' and 'SupplierID' to not be visible On Load for the form? So that the person filling out the form has no choice but to select one of the checkboxes. Still has to be a Macro since its a Web database.
 
I think I got the On Load visibilty.

I SetProperty on each field to Visible False in the On Load for the form. And its working like I want.
 

Users who are viewing this thread

Back
Top Bottom