Forms and Subforms

G

Guest

I have a form that has 2 embedded subforms on it. I also have 2 toggle
buttons on the form.
What I am curious about is whether there is a way that I could have both
subforms "hidden" unless the appropriate toggle button is clicked. For
example, if Toggle1 is clicked then it would display subform1, and subform2
would remain hidden. However, if Toggle2 is clicked, then subform1 would
remain hidden and subform2 would display.
 
G

Guest

Hi Steve,

Yes, it's quite an easy one.

Create an 'on change' event for the selection group that contains the two
toggle buttons. The coding runs like this:

DoCmd.RunCommand acCmdSaveRecord
Select Case Me!OptionGroup
Case 1
Me!Subform1.Visible=True
Me!Subform2.Visible=False
Case 2
Me!Subform1.Visible=False
Me!Subform2.Visible=True
End Select

(If the buttons aren't part of an option group but are independent command
buttons, just put lines 3 & 4 on the coding for button 1, and lines 6 & 7 on
button 2). The first line (saving the record) is a hard lessonm to learn -
there are a number of circumstances where Access doesn't always respond to
the last changed item unless you force it.

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top