Switch to subform using a command button

T

Tara

Sorry this is so long, but I want to be sure I'm clear...I'm creating a form
that contains basic contact information for clients. I need to create
subforms linking related information from several other tables, but there
isn't enough room on the main form for the number of subforms I need. Also,
I don't really like the look of subforms, so even a tab control won't
accomplish what I want. I know I can use command buttons with some coding
behind them, but I'm thinking there may be a way to accomplish this more
easily. As I was first *playing* with the idea, trying to decide what to do,
I used the form wizard and chose data from two different tables (one being
what I want on the main form, another from one of the tables I planned on
using as the source for a subform) just to see what I kind of options it
would give me for displaying the data. It gave me the option of using a form
with a subform OR Linked forms. I chose Linked forms and it did exactly what
I had hoped and placed a command button on the form to open the *subform*.
But, when I try to use data from more than two tables, that option is no
longer available and it simply puts all of the data from all of the tables on
the main form. How can I get Access to let me create a command button (and
do it as easily as it did for one subform) for each subform?

Here's the code from the one command button it created:

Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err

If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If

ToggleLink_Click_Exit:
Exit Sub

ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit

Thanks in advance for any help!
 
J

Jeff C

Tara said:
Sorry this is so long, but I want to be sure I'm clear...I'm creating a form
that contains basic contact information for clients. I need to create
subforms linking related information from several other tables, but there
isn't enough room on the main form for the number of subforms I need. Also,
I don't really like the look of subforms, so even a tab control won't
accomplish what I want. I know I can use command buttons with some coding
behind them, but I'm thinking there may be a way to accomplish this more
easily. As I was first *playing* with the idea, trying to decide what to do,
I used the form wizard and chose data from two different tables (one being
what I want on the main form, another from one of the tables I planned on
using as the source for a subform) just to see what I kind of options it
would give me for displaying the data. It gave me the option of using a form
with a subform OR Linked forms. I chose Linked forms and it did exactly what
I had hoped and placed a command button on the form to open the *subform*.
But, when I try to use data from more than two tables, that option is no
longer available and it simply puts all of the data from all of the tables on
the main form. How can I get Access to let me create a command button (and
do it as easily as it did for one subform) for each subform?

Here's the code from the one command button it created:

Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err

If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If

ToggleLink_Click_Exit:
Exit Sub

ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit

Thanks in advance for any help!

You can use a combobox with a list of forms, and a button that opens the
form chosen in the combobox. This reduces the amount of space necessary
on the mainform.


Another option is to have a button for each form that you want to open,
which requires more space on the mainform.

Both of these options presume that you want to open the details forms as
individual forms, not subforms.

Another option is to have one subform on your mainform and one button
for each subform you want. Pressing each button changes that subform to
the one you want. So, you only need space for one subform and each
button. You could also use the combo box and one button and one
subformControl.

Hope these ideas help you some,

Jeff C
 

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