1

I'm trying to append records from one table to another, the code I have works but I want to change one of the values being inserted so it populated from the main form not the table where the records are being copied from

Is it possible to populate the [Job Number] Feild from the JbNum variable??

Dim db        As DAO.Database
  Dim strSQL    As String
  Dim PrtNbrGt  As String
  Dim JbNum     As String
  
  JbNum = Me.[tblManufactured.Job Number]
  PrtNbrGt = Me.SCSPartNumb

Set db = CurrentDb
strSQL = "INSERT INTO tblMaterialRequiremnt ( [Customer Part Number], [Job Number] ) " & vbCrLf & _
"SELECT tbl_BOM_Requirments.RequiredMaterialPrtNum, tbl_BOM_Requirments.ID " & vbCrLf & _
"FROM tbl_BOM_Requirments " & vbCrLf & _
"WHERE (tbl_BOM_Requirments.PrtNmber_LinkField) = """ & PrtNbrGt & """"

[Job Number] = JbNum

db.Execute (strSQL)

1 Answer 1

1

Try this:

Dim db        As DAO.Database
Dim strSQL    As String
Dim PrtNbrGt  As String
Dim JbNum     As String
  
JbNum = Me.[tblManufactured.Job Number]
PrtNbrGt = Me.SCSPartNumb

Set db = CurrentDb
strSQL = "INSERT INTO tblMaterialRequiremnt ( [Customer Part Number], [Job Number] ) " & vbCrLf & _
"SELECT tbl_BOM_Requirments.RequiredMaterialPrtNum, tbl_BOM_Requirments.ID, '" & JbNum & "' & vbCrLf & _
"FROM tbl_BOM_Requirments " & vbCrLf & _
"WHERE (tbl_BOM_Requirments.PrtNmber_LinkField) = """ & PrtNbrGt & """

db.Execute strSQL
Sign up to request clarification or add additional context in comments.

2 Comments

Hi Gustav, thanks for your help.. its caused a compile error/syntax error expected end of statement on the FROM line
Got It... its working now.... Thanks very much..."SELECT tbl_BOM_Requirments.RequiredMaterialPrtNum, '" & JbNum & "'" & vbCrLf & _

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.