Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    8

    Unanswered: Append + Delete + Update Query

    Hello, I was wondering if someone could help me out with this. I have now three Queries to perform one action. The first appends data to another table, the update query updates a field in this record with the current date, and the third query deletes the original record from the first table. I can combine these in a macro, but I still have to type in the record number three times. Is there a way to "forward" the record number to the other two queries? That way I would only have to type in one number to perform the action.

    Thanks for any help,

    Joe
    Last edited by josterloh; 01-14-05 at 15:21.

  2. #2
    Join Date
    Apr 2002
    Location
    Portugal
    Posts
    146
    Hi,

    You can use VB to do that!

  3. #3
    Join Date
    Jul 2004
    Posts
    8
    Could you give me an Idea of where to start with that.

  4. #4
    Join Date
    Apr 2002
    Location
    Portugal
    Posts
    146
    I think you have a form where you input the records.

    In that form design a button and when the assistant button builder opens, chose cancel. Then rightclick the button and choose properties, choose the tab event procedures and select On Click Event, click on the three dots on the right and choose Visual Basic, A programing window appears, then enter the following senteces:

    Docmd.OpenQuery "name of your first query"
    Docmd.OpenQuery "name of your second query"
    Docmd.OpenQuery "name of your third query"

    Now in the menu, choose Debug and then Compile, and your done.

    Now when you click on that button, the code runs executing the first query, then the second and finaly the third.

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you may also want to wrap these three queries in an explicit transaction so that either all three queries complete correctly or everything is reset to it's initial state.

    the DAO code methods for explicit transactions are BeginTrans, CommitTrans, Rollback. you have some google research ahead of you

    izy
    currently using SS 2008R2

Posting Permissions

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