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

Dialog box not closing

Status
Not open for further replies.

robherms

Programmer
Sep 5, 2006
1
US
I have the following line of code in a module to open a dialog box:

Do While rstCBAPPS.EOF = False
If rstCBAPPS.Fields("ACAP No") = Val(strACAP) Then
'Open error dialog with error message
strErrorMessage = "Duplicate Found! Press Cancel to enter title manually."
DoCmd.OpenForm "frmduperror", WindowMode:=acDialog
'0 = Dup, 1 = Contin, 2 = New, 3 = Cancel
If intResponce = 3 Then
MsgBox ("Title Number: " + publicTitleNumber + " has not been entered.")
publicTitleNumber = Val(publicTitleNumber) + 1
rstCBAPPS.Close
Exit Function
End If
End If
rstCBAPPS.MoveNext
Loop

With the following code in the doalog box form:

Private Sub cmdDup_click()

intResponce = 0

DoCmd.Close

End Sub

Private Sub cmdContin_click()

intResponce = 1

DoCmd.Close

End Sub

Private Sub cmdNew_click()

intResponce = 2

DoCmd.Close

End Sub

Private Sub cmdCancel_Click()

intResponce = 3

DoCmd.Close

End Sub

Private Sub Form_Load()

Label12.Caption = strErrorMessage

End Sub



When the responce on the newly opened dialog window is cmdCancel (3) everything continues normally. However if anything else is chosen, you have to click on the command button 6 times in order for it to register. If I try to dabug the code and walk though, the program exits on the DoCmd.Close statement. Does anyone know why this would be happening?

Note: intResponce is declared publicly
 
robherms,
Do you have to click on the button six times because your dialog box is opened six times, are there six more records where [tt]rstCBAPPS.Fields("ACAP No") = Val(strACAP)[/tt]?

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top