none
Make Table SQL statement RRS feed

  • Question

  • Hi all,

    I need to make a backup of certain tables in my Access 2013 database. I want to assign my own table name with the date as a suffix. I am using the below code:

    Set dbs = CurrentDb
    Dim NewTableName

    NewTableName = "ReOrderTableBackup_" & Date
    dbs.Execute "SELECT ReOrderTable.ID, ReOrderTable.StkCode, ReOrderTable.Descr, ReOrderTable.SOH, ReOrderTable.MinQty, ReOrderTable.ReOrderQty, " _
                & "ReOrderTable.QtyToOrder, ReOrderTable.PONo, ReOrderTable.DateRequested, ReOrderTable.DateRequired, ReOrderTable.DateSentToBuyer, " _
                & "ReOrderTable.QtyOnOrder, ReOrderTable.QtyReceived, ReOrderTable.DateReceived, ReOrderTable.StockOut, ReOrderTable.DateOfOrder INTO " _
                & "" & NewTableName & " IN 'Y:\PL Chemserve\NEW PL System Backend\Packing List ReOrderTable Backups.accdb' FROM ReOrderTable;"
    dbs.Close

    Running the code, gives me an error 3067: "Query input must contain at least one query or table".

    Can anybody shed some light what the mistake may be?

    Much appreciated

    Deon

    Tuesday, February 28, 2017 9:52 AM

Answers

  • Hi all,

    I found my mistake. I omitted the brackets ("["). It is working fine now.

    Thanks!!

    Deon

    • Marked as answer by Deon SA Tuesday, February 28, 2017 10:22 AM
    Tuesday, February 28, 2017 10:22 AM