Closing a form vs. Really closing a form

bob bisquick

Registered User.
Local time
Today, 17:23
Joined
Nov 8, 2002
Messages
37
This is related to some advice I received some time ago <a href="http://www.access-programmers.co.uk/forums/showthread.php?t=64818">here<a>

I am runnign some code, it performs some applications, then, if a Count Field is greater than 1, a form opens as a dialog, displaying some information:

Dim A As String
A = "NewForm"
If Me.[Count] > 0 Then
DoCmd.OpenForm A, acNormal, , , , acDialog
End If
If Me.Continue = "No" Then
Exit Sub

End If

The new form opens, and you can either view it, and click continue, which will run the rest of the code, or you can click quit, which updates Me.Continue to "No", and then it exits.

The problem is, when it exits the Sub, it doesn't really stop the code, it just leaves things kind of hanging. When I try to run the code again, I get:

3321 - The database engine could not lock the table 'NewTable' becuase it is already in use by another person or process.

Another symptom - The original form where I click to start running the code, has two date fields. Normally, when this form opens, they are blank, but when I exit the sub, as above, the previous dates I entered are still sitting there.

How can I make the forms really close?
 
Bob,

Code:
Dim A As String
A = "NewForm"
If Me.[Count] > 0 Then
   DoCmd.OpenForm A, acNormal, , , , acDialog
End If
'
' Bob, the code DOES NOT stop here and wait
' for something to happen on the form.  By the
' time the form opens, this next line of code
' will already have executed.
'
If Me.Continue = "No" Then
   Exit Sub
End If

If the form does a DoCmd.Close, the form will close.
It must not be doing a DoCmd.Close

Wayne
 
I figured out a whole different way to present the info that eliminates that problem completely. Thanks.
 

Users who are viewing this thread

Back
Top Bottom