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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop a module; then re-execute after criteria met

Status
Not open for further replies.

snoopy92211

Technical User
Jun 29, 2004
67
0
0
US

I have this function that updates a table, tblTable with additional fields, etc. That all works fine and dandy. However, I have to check if a code in tblTable matches with a code in tblMaster. That also works fine and dandy. If the code doesn't match in tblTable, I have a form that pops up in the module with the missing name. The user can then update the name and the module can continue with appending the fields.
Here is my problem. How can I pause/stop the module if this criteria is true (meaning the name is missing); when they enter the information itno the form, the code re-executes and checks the name. No names are missing from tblTable, and it updates/appends the correct fields.

here's the code:

Code:
Dim rstlocations As DAO.recordset
Set rstlocations = db.openrecordset("tbltable Without Matching tblmaster")
If rstlocations.RecordCount = 1 And rstlocations.BOF = rstlocations.EOF Then

    DoCmd.OpenQuery "Updatew/Name", , acEdit
    DoCmd.OpenQuery "qry1" , acEdit
    DoCmd.OpenQuery "qry2", , acEdit
    DoCmd.OpenQuery "qry3", , acEdit
    DoCmd.OpenQuery "qry4", , acEdit

Else
MsgBox "You have not added all the Names to the database. You will not be able to" _
& " Import the table unless you add all the Names", vbExclamation, "Error"
DoCmd.OpenForm "Unmatched", , , "Name <> ' '"
Exit Function
End If

Call CheckforMatches
 
Use the acDialog option when opening the form:

[tt]DoCmd.OpenForm "Unmatched", , , "Name <> ' '",,acdialog[/tt]

This will halt execution until the form is closed. So when hitting your close button on this form, store the name, or whatever you wish to store, in a public variable you can retrieve in the following the openform line.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top