Command button (Open Form)

lead 27

Registered User.
Local time
Yesterday, 21:06
Joined
Mar 24, 2007
Messages
147
Hello

I am very new to Access and I thought that I had it sorted but now im stuck!

I am trying to set up a database where i can type in a serial number and it will take me to the form that referes to that number, I have filled in the table and made a form that displays the information in my table however my problem is that when i set up a form in design view and open a command button I choose open form then select my table the open form and find specific data to display an error window opens saying that "You have chosen forms taht can't be linked. You must have at least one field that can be linked on each form.

I have got this to work once but I have no idea how

Im sure that it is a simple thing but I dont know what to do can anyone help?
 
The error is telling you that the form that opens with the command button needs to have at least one field in common with the form that it is being opened from.

If you have a control on the form that you have the button on, contains the serial number, then you can open the other form like this:
Code:
DoCmd.OpenForm "YourFormNameHere",acNormal,,"[YourSerialNumberFieldNameHere]=" & Me.YourControlNameHere
The part YourSerialNumberFieldNameHere should be replaced by the actual name of the field on the form you are trying to open that houses the serial number.

The part Me.YourControlNameHere is the name of the control on your current form that has the serial number in it. Me. is a shortcut that refers to the current form and you can use it if the code that you are coding is on that form.
 

Users who are viewing this thread

Back
Top Bottom