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

Need help appending multiple records with VBA

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
I hope I can explain what I'm doing here.
1. I've created a form in which users enter production as well as scrap pieces.
2. If they have scrap I create a table using their clock number (I.D.#) for the name.
3. I then send that information to a list box so they can examine what they are putting in to the list.
4. When they are done the user will push a button and all the production information gets sent to one table (via SQL) and the scrap information needs to go to the Scrap table.
5. I then delete the clock number table and all should be done.

Appending mulitple records to the Scrap table is what I'm having a hard time doing or understanding.

Here is the code for what I have. tbltempscrap is the table I'm trying to Append the records to from my clocknumber table.


Private Sub cbaddreport_Click()
Dim strclocknumber As String, strSQL As String
strclocknumber = Me.tbclocknumber.Value
Me.lbstuff.RowSource = ""
strSQL = "INSERT INTO tbltempscrap ([Clock number,Partnumber,Operation,Rate " _
& " SELECT " & strclocknumber & "[Clock number],Partnumber,Operation,Rate" _
& " FROM tbltempscrap;"
DoCmd.RunSQL strSQL
DoCmd.DeleteObject acTable, strclocknumber
End Sub

Need more info just post back please.

There is probably a better way of doing what I'm trying to do and maybe that would be my answer.



Rib

Bartender:Hey aren't you that rope I threw out an hour ago?

Rope:No, I'm afraid knot.
 
I think I've figure it out. This is what I have in case anyone is at all curious.

Private Sub cbaddreport_Click()
Dim strclocknumber As String, strSQL As String
strclocknumber = Me.tbclocknumber.Value
Me.lbstuff.RowSource = ""
strSQL = "INSERT INTO tbltempscrap SELECT [" & strclocknumber & "].* FROM " & strclocknumber & ";"
DoCmd.RunSQL strSQL
DoCmd.DeleteObject acTable, strclocknumber
End Sub

Thanks, Rib

Bartender:Hey aren't you that rope I threw out an hour ago?

Rope:No, I'm afraid knot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top