Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    106

    Unanswered: What is wrong with my code?

    strQuery = "INSERT INTO tbl_Rates ([Stop or Route Name], [Requestor]) SELECT ('" & Me.Route_Name & "', '" & Me.Requestor & "')"
    CurrentDb.Execute (strQuery)

  2. #2
    Join Date
    Dec 2003
    Posts
    268
    strQuery = "INSERT INTO tbl_Rates ([Stop or Route Name], [Requestor]) VALUES ('" & Me.Route_Name & "', '" & Me.Requestor & "')"

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    INSERT INTO has two syntax possiblities:

    INSERT INTO targetTable (field1, field2)
    SELECT field1, field2
    FROM originalTable

    or

    INSERT INTO targetTable (field1, field2)
    VALUES ('value 1', 'value 2')

    So, you're statement needs to be:
    strQuery = "INSERT INTO tbl_Rates ([Stop or Route Name], [Requestor]) VALUES ('" & Me.Route_Name & "', '" & Me.Requestor & "')"


    edit: damn, beaten by a minute.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Feb 2004
    Posts
    106
    That worked! Thank you both.

    Quote Originally Posted by Teddy
    INSERT INTO has two syntax possiblities:

    INSERT INTO targetTable (field1, field2)
    SELECT field1, field2
    FROM originalTable

    or

    INSERT INTO targetTable (field1, field2)
    VALUES ('value 1', 'value 2')

    So, you're statement needs to be:
    strQuery = "INSERT INTO tbl_Rates ([Stop or Route Name], [Requestor]) VALUES ('" & Me.Route_Name & "', '" & Me.Requestor & "')"


    edit: damn, beaten by a minute.

Posting Permissions

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