Results 1 to 4 of 4

Thread: syntax error

  1. #1
    Join Date
    Apr 2013
    Posts
    2

    Unanswered: 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

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    instead of (Document Number)
    try
    ([Document Number])

    the problem is that you are using spaces in column/table names . in an ideal world you shouldn't use spaces but there is a work around, using square brackets to denote the start and end of a table/column name.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2013
    Posts
    2
    I have tried that, as well as several other iterations...I keep getting...
    Syntax Error (missing operator) in query expression '[Document Number]='

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    well at least its a step forward that you have supplied the error message


    check the value of stLinkCriteria, make certain its valid
    is me![Document Number] valid
    is it numeric or string
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •