Quantcast
Viewing all articles
Browse latest Browse all 13329

syntax error

I’ve tried several iterations of this ‘INSERT INTO’ statement…and it keeps telling me there is a syntax error.
It’s an event procedure from a data entry form (form_AdminRecord) that opens a second form for attachments, when you click on the button.
It will open the second form (form_Attachment) without any issues, but I can’t get the ‘Document Number’ to carry over.
I want the Document Number to carry over to the second form when it’s opened.
Document Number is a linked field in both underlying tables (tbl_AdminRecord, tbl_Attachment) for the two forms.



Private Sub Show_Attachments_Click()
On Error GoTo Err_Show_Attachments_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "form_Attachment"

stLinkCriteria = "[Document Number]=" & Me![Document Number]
'DoCmd****nSQL "INSERT INTO tbl_Attachment (Document Number) SELECT tbl_AdminRecord.Document Number FROM tbl_AdminRecord"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Show_Attachments_Click:
Exit Sub

Err_Show_Attachments_Click:
MsgBox Err.Description
Resume Exit_Show_Attachments_Click

End Sub

Viewing all articles
Browse latest Browse all 13329

Trending Articles