Check box to trigger event

poetdi

Board Regular
Joined
Nov 28, 2002
Messages
70
Hello - this should be really simple but I'm out of practice. I've tried using a macro as follows:
I have a form with a checkbox. I'd like, when the user checks the box, for another box to appear. I have that box set to invisible.
I created a macro, and all it is supposed to do is change the property of the box to visible. I've assigned that macro to the On Click event of the checkbox.
When I check the box I get the following error:
"An expression in argument 3 has an invalid value.
You tried to run a macro or used the DoCmd object in Visual Basic. The argument number above is the position of the argument as it appears in the Macro window, the Action Failed dialog box, or the Object Browser (if you're using the DoCmd object)."
When I clear that message, I get the Macro Single Step dialog box which lists the macro name, a blank condition box (because there aren't really any), the Action Name (which is SetProperty) and the Arguments box, which has the name of the field I want to make visible, then the number 1.
The error number is 2505.
All I want to do is have the user check the box, and make this box appear. Otherwise, I don't want the box to appear.
Any suggestions welcome. I feel like a very silly person but, oh well!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
The easiest way is to not use a macro for this but use VBA. It is easy - in the event property of the checkbox (use the After Update event) you select [Event Procedure] from the drop down and then click the Ellipsis (...) to the right of it. It will open the VBA window to the code like this (I am using MyCheck as my checkbox name. Yours would be whatever it really is):

Code:
Private Sub MyCheck_AfterUpdate()
   Me.MyTextBoxNameHere.Visible = Me.MyCheck
End Sub

So it will show if it is checked and not if not checked. You will also need to call this code in the form's On Current event. You can do that by going to the form in design view (from being open) and then in the On Current event you select [Event procedure] and click the Ellipsis (...) like before and then put
Code:
Private Sub Form_Current()
   MyCheck_AfterUpdate
End Sub
The only thing you would replace is your actual checkbox name for MyCheck. Everything else stays the same.
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,654
Members
452,934
Latest member
mm1t1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top