Hiding Menus

saint_2008

Board Regular
Joined
Sep 6, 2007
Messages
103
Hi hopefully someone can help, I'm trying to Hide some fields on my form when I select option on my toggle box.

I've tried doing it a few different ways but not sure as I'm very new to access.

This is what I have...

Private Sub Toggle10_KeyPress(KeyAscii As Integer)

Me.Equipment_ID.Visible = False
Me.Equipment_Type.Visible = False
Me.Manufacturer_Name.Visible = False
Me.Label18.Visible = False
Me.Label19.Visible = False
Me.Label20.Visible = False

End Sub

Private Sub Toggle11_KeyPress(KeyAscii As Integer)

Me.Equipment_ID.Visible = True
Me.Equipment_Type.Visible = True
Me.Manufacturer_Name.Visible = True
Me.Label18.Visible = True
Me.Label19.Visible = True
Me.Label20.Visible = True

End Sub

Any Idea why it doesn't work?

Many Thanks
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi hopefully someone can help, I'm trying to Hide some fields on my form when I select option on my toggle box.
I've tried doing it a few different ways but not sure as I'm very new to access.
Any Idea why it doesn't work?
Many Thanks
Not telling us what other ways you've tried may result in us suggesting what you've already tried.
To me, it looks like you have it on the wrong event if you want this to trigger after a "toggle box"??? update. I presume you mean combobox. In that case, put your code on the combobox After_Update event. Or do you mean an option group? I doubt you mean toggle button.
 
Upvote 0
Hi Micron,

Thank you first of all for trying to help, and sorry for any confusion I'm very new to Access and databases in general,

I was using the Option Group" (XYZ Icon with out the image) to create the "Menu buttons" when I was going though my steps to tell you I realised there was an option for Mouse Down under event so I've tried it and its all working now as I wanted, I original tried on "Key Press Down" I'm guessing this is a keyboard press.

But all sorted now and Thanks for you time.
 
Upvote 0
Sounds like you have managed; kind of like putting the screw back in with a knife instead of a screwdriver if you get my drift. It works, but you should know of the correct method because it saves effort (or fingers, depending on what we're talking about).
I gather now that you have option buttons in an option group. For this type of interaction, option buttons are supposed to be contained within a type of frame know as an Option Group. The buttons are assigned numeric values via the property sheet, and when one is chosen, the value is passed to the frame/group automatically. In code, you refer to the value of the group. Even if there are only two choices at the outset, IMHO it's best to start with a Select Case block as it's easy to expand on it in the future. If no prior validation is required (the group has an acceptable default value, for instance) the trigger event can be the After_Update for the group. So on your form, you would have something like
Code:
Dim intOptVal as Integer
intOptVal = Me.MyOptionGroupName

Select Case intOptVal
 Case 1
   Do stuff
 Case 2
   Do other stuff
End Select
For those who might wonder, yes we could reference the control in the Select block instead of coding to declare, set and reference a variable. I usually do it this way so that I can manipulate the value of a variable or a property in the vbe immediate window in break mode while debugging. While you can get or set that value or property by referring to the parent object, it's often less typing to reference the variable rather than the hierarchy of the control or property. Besides, often you cannot manipulate the value of a control because it is bound or otherwise not updateable.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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