Command button that opens form

J

jped

I am trying to create a command button on my switchboard form that opens
another form based on user input. I would like to have the user click the
button, have Access ask for the Order Number, than have it pull up that order
form. When going through the Form Wizard, I get the following error when I
click on Open the form and find specific data to display:

You have chosen forms that can't be linked. You must have at least one
field that can be linked on each form.

Is there a way to fix this or is there code that I can enter manually to
open the form and display the data based on the user inputting an order
number? Please Help!

Thanks!
 
S

Sprinks

Not sure what the wizard's doing, but assuming you have a combo box (or
textbox) that allows you to select or enter an order number, the code for
your button is:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourFormName"

stLinkCriteria = "[OrderNumber]=" & Me![YourComboOrTextBox]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks
 
J

Jason

What the wizard is telling you is that there is no field on your switchboard
that relates to the field you're trying to filter on the order form. As
Sprinks suggests, you need to create another form that has either a combo box
or text box or something that will take the users input. You then have the
switchboard open the combo box form. The use then selects the order no or
types it in or whatever you want to do to accept input from the user and
using the coded that Sprinks gave you the combo box form opens the order
form. Hope that all made sense.
 
J

jped

Thanks for your help. I see what you guys are saying and that makes sense.
I'll let you know if I have any problems. Thanks again!

I am having another issue, of course, which I am posting. Maybe you can
help me with this as well.

Thanks
 
F

Five

I'm having the same problem, but I'm afraid I'm not as advanced as the
previous poster. I have an employee database. On the switchboard, I
would like for the employees to be able to pull up their own record. I
got the message about "You have chosen forms that can't be linked." so I
did two things: 1. In Switchboard manager I created a new page for a
Combo Box. 2. Using Form Wizard, I created a form that shows only the
ConsultantName label and the ConsultantName combo box that pulls the
names from the main table.

I tried using the code that has been posted here, but am not sure what
to put in for ""[OrderNumber]" and "[YourComboOrTextBox]." When I
tried plugging in ConsultantName (which is the name of the field and
the combo box), I get an error saying I need to debug.

So I'm guessing that I'm missing some critical step that links the
forms together and makes this feature work. I'm checking my Access
2003 Bible, but haven't found the answer yet.

Thanks in advance.



Not sure what the wizard's doing, but assuming you have a combo box (or
textbox) that allows you to select or enter an order number, the code
for
your button is:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourFormName"

stLinkCriteria = "[OrderNumber]=" & Me![YourComboOrTextBox]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Hope that helps.
Sprinks

:
-
I am trying to create a command button on my switchboard form that
opens
another form based on user input. I would like to have the user click
the
button, have Access ask for the Order Number, than have it pull up
that order
form. When going through the Form Wizard, I get the following error
when I
click on Open the form and find specific data to display:

You have chosen forms that can't be linked. You must have at least
one
field that can be linked on each form.

Is there a way to fix this or is there code that I can enter manually
to
open the form and display the data based on the user inputting an
order
number? Please Help!

Thanks!-
 
Top