List box to form

jbphoenix

Registered User.
Local time
Today, 16:33
Joined
Jan 25, 2007
Messages
98
I have 2 forms setup. The user enters a part ID and date range then clicks a button to display the results in a listbox. From there I would like the user to double click the record they are looking for and then have the other form open so they can edit the record. I can get the second form to open but it doesn't have the record on it. The form is blank.

Here is the code I have -
DoCmd.OpenForm "QA_Supplier_Quality_Lot_Edit_TEST_frm", , , "Receiver_ID_txt= " & Me!List7

Receiver_ID_txt is on the second form. It's the unique ID.

How do I get the data to the second form?
 
Is "Receiver_ID_txt" the name of the data field, as it needs to be? Is the listbox multiselect, which would require a bit of code?
 
Remember that the list box is probably using the ID number and not the text. So, it would be either:
Code:
DoCmd.OpenForm "QA_Supplier_Quality_Lot_Edit_TEST_frm", , , "Receiver_ID= " & Me!List7

or if List7 is returning text
Code:
DoCmd.OpenForm "QA_Supplier_Quality_Lot_Edit_TEST_frm", , , "Receiver_ID_txt=[b][color=red]'[/color][/b]" & Me!List7[color=red][b] & "'"[/b][/color]
 
Oh, I was using the name of the control and not the name of the field in the table. I'll try changing it and see what happens.
 
Well now I'm coming up with a Run Time error when I double click on the entry in the list box.

Run-time error '3075':
Syntax error (missing operator) in query expression 'Receiving Lot Number = 15035'

Here is my coded:
DoCmd.OpenForm "QA_Supplier_Quality_Lot_Edit_TEST_frm", , , "Receiving Lot Number = " & Me!List7
 
Try this instead:

DoCmd.OpenForm "QA_Supplier_Quality_Lot_Edit_TEST_frm", , , "[Receiving Lot Number] = " & Me!List7
 
My apologies on in advance for using an existing thread but I thought it would be best rather than start a new on.

I have used Bob's code but I get the following error message;

Runtime error

Syntax error (missing operator) in query expression '[lngSalesOrderID]=".

Here is the code I am using

Code:
DoCmd.OpenForm "frmSalesOrders", , , "[lngSalesOrderID] = " & Me!lstSalesOrders

Kind Regards in advance

Peter
 
Is the listbox multiselect?
 
Thanks pbaldy that was exactly the problem

working on a sunday morning in Scotland sure fuzzes the brain....

Cheers
 

Users who are viewing this thread

Back
Top Bottom