• Code/SQL experts help..

    Author
    Topic
    #352470

    I run this code from a button on a form.. When I run the code it gives me an error ‘Run-Time error ‘3134’ Syntax error in INSERT INTO statement.. Obviously the error deals with the INSERT INTO part of the SQL statement, but I checked the “SELECT” part of the SQL and it does pull the data I need.. So that part is correct.. Program is a string for the name of the table I want to insert the data into.. Appendtable is a string for the name of the table I want to select the data from… I even tried building the SQL as an append query and using that SQL but I got the same error.. Any thoughts? Thanks

    Dim Program As String
    Dim AppendTable As String
    Program = pgmtbl
    AppendTable = Program & “Resolutiontbl”

    DoCmd.RunSQL “INSERT INTO ” & Program & “SELECT ” & AppendTable & “.[Voucher#],” & AppendTable & “.[First Name],” & AppendTable & “.[Last Name],” & AppendTable & “.[Appt#] FROM ” & AppendTable & ”

    Viewing 0 reply threads
    Author
    Replies
    • #512714

      Hi Gary,
      Firstly, unless pgmtbl is a variable, you need to change your code to read:
      Program = “pgmtbl”
      It’s also unclear on my screen how you’ve ended the SQL statement – it looks like your code ends in & ”
      It needs to end in “;” instead I think. I’d also check to make sure you’ve got a space before the SELECT statement (otherwise your string becomes ‘INSERT INTO pgmtblSELECT’ which might throw Access off track.
      Hope that helps!

      • #512846

        Thanks Rory. It was getting late in the day when I posted that.. I was getting pretty tired.. I hope you’ve been well and thanks again..

    Viewing 0 reply threads
    Reply To: Code/SQL experts help..

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: