Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two forms on the same record

Status
Not open for further replies.

lalee5

Technical User
Oct 20, 2002
70
US
Please help! Thank you in advance

form1 ado to product table
form2 ado to inventory table


I have two forms. When I am on form1 I pull up a record. the record has a unique product number. When I click a command button to go to form 2 I want form 2 to pull up records matching the product no. on form 1.

I did try to search all threads but seems like nothing really does what I want.


Thanks


Kay
 
On the form_load event, make your ado connection and fill in all of the appropriate fieds based on the the product number's field. ie:

SQL = "SELECT * FROM TABLE WHERE PRODUCT_NUMBER = '" & form1.productfield.text & "'"

Assuming your product# is a text type field sitting in a textbox on form1.
 
That's fine, but you might also consider putting this in the form_activate event. This way, you don't have the overhead of loading and unloading the form; you can just hide and show. Also, you don't have to make the ado connection in the detail form. You just have to open and close the recordset, and you can reference the connection that you are using in the first form from the second, e. g.

myRs.open mySQLString, form1.myConnection

This code should be in the form2_activate, and the ok button or whatever on form2 should close the rs and do a me.Hide. One more thing: you might want to prevent the user hitting the x on form2 by canceling in the unload event and calling the ok button's click event.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top