Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Must Call Docmd.RunQuery Twice to Work Properly

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
Hi. I have a command button click event which calls 2 INSERT INTO queries. The first query inserts a 'master' record and the second query inserts 'detail' records. When I click the button the first time it seems that only the first query executes, as I can see the 'master' records but not the 'detail' records. But if I click the button again I can then see the detail records. So basically I need to click the button twice in order to have both queries complete successfully.

I thought that this issue may be related to the fact that the 2nd query was executing too soon before the first 'master' record was created. Therefore I added a 5 second timer between the 2 queries, but I received the same results and still needed to click the button twice.

Any ideas how I can work around this problem? Thanks!
Code:
Private Sub cmdDebitMemo_Click()

    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryConvertPOToCM"       'create master
    DoCmd.OpenQuery "qryConvertPOToCMDetail" 'create detail
    DoCmd.SetWarnings True

End Sub


--
Not until I became a Network Administrator did the error message "See your Network Administrator for assistance" become petrifying.
 
I've found the solution. I needed to call a subform requery, as a control on that form was feeding the query. This is fixed now. Thanks.


--
Not until I became a Network Administrator did the error message "See your Network Administrator for assistance" become petrifying.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top