Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002
    Location
    London
    Posts
    1

    Red face Unanswered: insert into statement & SQL

    I am running Access '97. I want to copy all records from a temporary table called "Import Interlink Despatch" into a log table called "Import Interlink Log". There are only 4 fields to copy and I have checked the field names.

    It's part of a module - and i don't want to use / call a append query. I
    want to use the "Insert Into" statement. Just cannot get this to work! Here is my code:

    Dim MyWorkspace As Workspace, MyDatabase As Database,
    Set MyWorkspace = DBEngine.Workspaces(0)
    Set MyDatabase = MyWorkspace.Databases(0)


    MyDatabase.Execute " INSERT INTO Import Despatch Log " & "SELECT * " & "FROM
    [Import Despatch Records];"


    I have had the feeling that my connection string may be incorrect - but this has worked with every other module I have run and I have never experienced any problems. Also, the Delete SQL statement that precedes the Insert Into statement runs fine.

    Please could someone put me out of my misery :-)

    Thanks. Simon.

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    I would try something like this:

    CurrentDB.Execute "INSERT INTO [Import Despatch Log] (field1, field2, field3, field4) SELECT field1, field2, field3, field4 FROM [Import Despatch Records];"

    HTH

Posting Permissions

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