Results 1 to 4 of 4
  1. #1
    dada is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    40

    Inserting values from one table to another

    here is my table structure

    Table Name: DTR


    Field Name - Data Type:
    EmpNum - Text
    Empname - Text
    Date - Date/Time
    Day - Text
    FIN - Date/Time
    FOUT - Text
    LIN - Date/Time
    LOUT - Date/Time

    Table Name: TempDTR
    Field Name - Data Type:
    F1 - Text
    F2 - Text
    F3 - Date/Time
    F4 - Text
    F5 - Date/Time
    F6 - Text
    F7 - Date/Time
    F8 - Date/Time

    here is my code:

    DoCmd.SetWarnings (False)
    Dim sql As String

    sql = "INSERT into DTR(EmpNum, EmpName, Date, Day, FIN, FOUT, LIN, LOUT) Select F1,F2, F3, F4, F5, F6, F7, F8 from TempDTR"
    DoCmd.RunSQL (sql)


    It gives me syntax error and i don't know why.. any idea? please help..

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Your field called Date is probably causing the problem since Date is a reserved word in Access (the Date() function). For the short term, you could enclose the field in square brackets.


    Code:
    sql = "INSERT into DTR(EmpNum, EmpName, [Date], Day, FIN, FOUT, LIN, LOUT) Select F1,F2, F3, F4, F5, F6, F7, F8 from TempDTR"
            DoCmd.RunSQL (sql)
    For the long term, it would be best to give the field a new name.

    Here is a link to a list of reserved words in Access 2010 and another link for Access 2003

  3. #3
    dada is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    40
    awesome! you nailed it! i got one more question but it's a different topic, so i'll just post another thread. thanks dude!

  4. #4
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Inserting multiple records into a table
    By New2Access in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 09:18 PM
  2. Replies: 2
    Last Post: 08-22-2010, 01:42 PM
  3. Inserting Multiple values
    By rajath in forum Access
    Replies: 1
    Last Post: 05-14-2010, 04:17 AM
  4. Replies: 3
    Last Post: 04-04-2010, 05:26 PM
  5. inserting values in column based another column
    By wasim_sono in forum Database Design
    Replies: 1
    Last Post: 06-27-2006, 05:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums