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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filing a table with avaible data

Status
Not open for further replies.

enigma12121

Programmer
Jul 16, 2001
6
US
I want to know an easy way to fill a record of a table with the data from another table

Here is goes. Right now I have two tables one is for shipping the other is the Sales Order behind it. When I want to ship an item I open the subform for shipping and it copies the Sales order number into the sub form. it then populates a drop down box with all the items in that order. I want to know how I can copy the rest of the data from the Sales Order Table into the Shipping table using only those two pieces of information.

THanks in advance
 
If the table structure between the two tables is identical, you can use an insert query executed from your VBA code to copy the data - eg

Code:
DoCmd.RunSQL &quot;INSERT INTO [Shipping] SELECT * FROM [Sales Order] WHERE [Sales Order Number]='&quot;&quot; <a variable or control reference containing your sales order #>&quot;&quot;

A slightly faster way would be to create a Querydef with the same SQL code then execute it.
If however the tables don't have the same structure, you can use a Recordset object and loop through, which is quite a bit slower, or use some fancy SQL to manipulate data as it is copied.

John
 
The porblem is is that I don't want to copy all of the sales orders. I only want to copy over the ones that match the Sales order number + the part number

But thanks for letting me see a differnt way of attacking the problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top