Command button that opens form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 
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.
 
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
 
Back
Top