Results 1 to 5 of 5

Thread: Appending/Deleting Records to Access DB using SQL in VB App

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Lakewood, CO
    Posts
    9

    Arrow

    I need to append a records based on a date from one Access table to another and then delete the same records from the origin table. I've got the query worked out but apparently am not making the correct reference to the data control. I'd appreciate an example if someone's got one available.

  2. #2
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    more info required...

    in what way are you not making the correct reference to the data control, e.g. how do you know your not (what error message do you get)?
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Lakewood, CO
    Posts
    9
    I tried setting the data control recordsource to "query statements" followed by a refresh. That gives an invalid operation. Is that the correct reference to preceed the query statements?

  4. #4
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    "query statements" ?

    i presume by this you are setting the recordsource to a sql statement. Are you sure the statement is correct - can you set the recordsource to a tablename you know exists?

    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I believe you can only use SELECT-type queries with the data control (which I hate to use), not "action" queries, such as INSERT or DELETE. I believe you want to do something like this (this example assumes that "NewTable" and "OldTable" have the same structure):
    Code:
    Dim MyDB As Database
    
    MyDB.Execute "INSERT INTO NewTable " _
               & "SELECT * FROM  OldTable " _
               & "WHERE OldTable.DateField = #1/1/2000#"
    MyDB.Execute "DELETE FROM  OldTable " _
               & "WHERE OldTable.DateField = #1/1/2000#"
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

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



Click Here to Expand Forum to Full Width