Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    45

    Unanswered: moving a row from a table to another table

    hallo,
    I have two table: contract, oldcontract. They have the same structure. I would like to move a row from a table to the other one.
    The code I'm using is the following and the error I get is: "Con_ID is an unknown field name"... any ideas?

    Dim sql As String
    Dim sql2 As String

    sql = "INSERT INTO tbl_OldContract SELECT * FROM tbl_Contract WHERE Con_ID =" & Me.Tim_ContractID & ";"

    sql2 = "DELETE * FROM tbl_Contract WHERE Con_ID =" & Me.Tim_ContractID & ";"

    DoCmd.RunSQL sql1
    DoCmd.RunSQL sql2

  2. #2
    Join Date
    Jan 2004
    Location
    Myanmar (Burma)
    Posts
    42

    Re: moving a row from a table to another table

    Originally posted by Davide77
    hallo,
    I have two table: contract, oldcontract. They have the same structure. I would like to move a row from a table to the other one.
    The code I'm using is the following and the error I get is: "Con_ID is an unknown field name"... any ideas?

    Dim sql As String
    Dim sql2 As String

    sql = "INSERT INTO tbl_OldContract SELECT * FROM tbl_Contract WHERE Con_ID =" & Me.Tim_ContractID & ";"

    sql2 = "DELETE * FROM tbl_Contract WHERE Con_ID =" & Me.Tim_ContractID & ";"

    DoCmd.RunSQL sql1
    DoCmd.RunSQL sql2
    Your code have a bug.
    Try with this.
    YourControlName.Value should replace with other properties depend on your control type.

    sql1 = "INSERT INTO tbl_OldContract SELECT * FROM tbl_Contract WHERE Con_ID = '" & YourControlName.value & "'"

    sql2 = "DELETE * FROM tbl_Contract WHERE Con_ID = '" & YourControlName.Value & "';"

    good luck!
    Cyber : The easiest place to make huge mistake.

  3. #3
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Re: moving a row from a table to another table

    Originally posted by Davide77
    hallo,
    I have two table: contract, oldcontract. They have the same structure. I would like to move a row from a table to the other one.
    The code I'm using is the following and the error I get is: "Con_ID is an unknown field name"... any ideas?

    Dim sql As String
    Dim sql2 As String

    sql = "INSERT INTO tbl_OldContract SELECT * FROM tbl_Contract WHERE Con_ID =" & Me.Tim_ContractID & ";"

    sql2 = "DELETE * FROM tbl_Contract WHERE Con_ID =" & Me.Tim_ContractID & ";"

    DoCmd.RunSQL sql1
    DoCmd.RunSQL sql2
    DavidE, do you have a Field in either table called Con_ID??? Check spelling etc. Just a thought.

    Bud

Posting Permissions

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