Hi All,
I'm trying to do an insert into query via VBA that takes the values of some controls in a form and puts them in to another table.
Basically frmPurchaseHistory, if a new record, will insert a new entry in to tblComponentHistory.
My Code is as follows but it is getting a syntax error:
When I print it to a message Box, it looks like this, and to me that's fine:
I would really value some help if possible.
Many thanks,
Simon
I'm trying to do an insert into query via VBA that takes the values of some controls in a form and puts them in to another table.
Basically frmPurchaseHistory, if a new record, will insert a new entry in to tblComponentHistory.
My Code is as follows but it is getting a syntax error:
Code:
Private Sub btnClose_Click()
Dim strINSERT As String
strINSERT = "INSERT INTO tblComponent (dtmDate, Component, History, Quantity, Update) " _
& "VALUES (#" & Format(Me.PurchaseDate.Value, "mm/dd/yyyy") & "#, " & Me.Component.Value & ", 2, " & Me.Qty & ", True);"
If OpenArgs = 1 Then
MsgBox strINSERT ' for debugging purposes
CurrentDb.Execute strINSERT ' run the insert query
End If
DoCmd.Close
End Sub
When I print it to a message Box, it looks like this, and to me that's fine:
I would really value some help if possible.
Many thanks,
Simon