FoxProProgrammer
Programmer
Hi folks,
A VB program counts the number of records in a table that have a null part. If the count is greater than 0, a form displays the number of undefined parts and presents the user with three buttons: Print report, Preview report, Cancel. The code to count the number of null records and call the form is:
emptyPartno = DCount("*", "Part", "isnull([cpart])"
If emptyPartno > 0 Then
DoCmd.OpenForm "Export Error", , , , , acDialog, emptyPartno
Here is the code in the "Export Error" form's command button OnClick procedures.
Private Sub btnCancel_Click()
DoCmd.Close
End Sub
Private Sub btnPreview_Click()
DoCmd.OpenReport "Undefined Parts", acViewPreview
DoCmd.Close
End Sub
Private Sub btnPrint_Click()
DoCmd.OpenReport "Undefined Parts", acViewNormal
DoCmd.Close
End Sub
Here's what happens when I run the program and emptyPartno is greater than 0. The Export Error form pops up. If I click on the Preview button, the report doesn't display and the form "Export Error" remains visible and active (I can click any of the three buttons), as if the Docmd.Close statement didn't execute. If I set a breakpoint and step through the code, the report opens in preview mode, the DoCmd.Close statement executes, and the "Export Error" form closes like it should.
Any idea why this is happening?
Thanks a lot,
dz
A VB program counts the number of records in a table that have a null part. If the count is greater than 0, a form displays the number of undefined parts and presents the user with three buttons: Print report, Preview report, Cancel. The code to count the number of null records and call the form is:
emptyPartno = DCount("*", "Part", "isnull([cpart])"
If emptyPartno > 0 Then
DoCmd.OpenForm "Export Error", , , , , acDialog, emptyPartno
Here is the code in the "Export Error" form's command button OnClick procedures.
Private Sub btnCancel_Click()
DoCmd.Close
End Sub
Private Sub btnPreview_Click()
DoCmd.OpenReport "Undefined Parts", acViewPreview
DoCmd.Close
End Sub
Private Sub btnPrint_Click()
DoCmd.OpenReport "Undefined Parts", acViewNormal
DoCmd.Close
End Sub
Here's what happens when I run the program and emptyPartno is greater than 0. The Export Error form pops up. If I click on the Preview button, the report doesn't display and the form "Export Error" remains visible and active (I can click any of the three buttons), as if the Docmd.Close statement didn't execute. If I set a breakpoint and step through the code, the report opens in preview mode, the DoCmd.Close statement executes, and the "Export Error" form closes like it should.
Any idea why this is happening?
Thanks a lot,
dz