Opening Form Based on Switchboard

  • Thread starter Thread starter S Jackson
  • Start date Start date
S

S Jackson

On my switchboard, the user selects a button and a dialog form with a list
box appears. The user makes selections from the list box and then a second
form opens using the listbox criteria from the dialog form.

What I would like to do is add another button to my switchboard, have the
same dialog form appear, but this time I want a second form (a different
form) to open.

How do I code my dialog form to open up the appropriate form based on the
switchboard selection? Is it possible?

TIA
 
Or maybe a better way to ask my question is:
"How do I ask VB to tell me which control is selected on a open form?"
 
Anything is possible!
Just use the OpenArgs argument of the OpenForm method to pass
the name of the form you want to open.
In your dialog form you would have code similiar to:

Select Case Me.OpenArgs
Case "thisForm"
'do your stuff here
Case "thatForm"
'do different stuff here
End Select
 
Oh boy. I'm lost. I am probably somewhere between a beginner and an
intermediate user of VBA. I understand objects, properties and methods.
But get lost on the argument stuff. Can you help me more?
When I have the Switchboard open and the Option1 control selected and then
do a Ctrl G and type:
?Forms!Switchboard.OpenArgs
I get "Null"

I don't understand how the dialog form is communicating with the Switchboard
to find out which control has been selected on the switchboard by using
Me.OpenArgs

Like I said - I'm so lost!
Help?
 
Hi,
The code you're using to open the dialog form is:

DoCmd.OpenForm "formName"
right?
Well, OpenForm has many other arguments, all of which are optional
which is why you don't see them very often.
Look this up in Help.

The one we are interested in is: OpenArgs which is the 7th and last one.
So...
OpenForm "fromName",,,,,,"nameOfOtherForm"

Now, when your dialog form opens, Me.OpenArgs will be:
nameOfOtherForm

That is how you can tell the form which other form it must open.
Make sense?
 
I am still totally and completely lost. I read the Help. I can barely
understand what it says. Never mind trying to apply it to my situation. I
guess the only solution for me is to create a second dialog form. This way
I can tell the switchboard to go to Dialog Form 1 if Option 1 is selected or
go to Dialog Form 2 if Option 2 is selected. Then I can code each Dialog
Form to open the appropriate Form. I know this is not an efficient way to
do things, but I don't have much choice.

Thanks for trying to help. Maybe some day I'll get it. I am one of those
people who can't learn just by reading it. I have to DO it - APPLY what
I've read. I don't think I am alone either, am I right?
 
I was re-reading your response and I couldn't help but notice that maybe I
didn't make it clear that the dialog form is being open by the Switchboard
which was created with the wizard.

Just fyi.
 
Hi,
I had forgotten what convoluted code the wizard wrote for the switchboard.
It's just too hard to customize. It does use OpenForm but it would be too difficult
to explain how to modify it for your purposes.
 
Back
Top