R
richard
Hi
I have a form [Sample Results] with a command button which runs a report
"Certificate Details", currently there is a question posed before the report
is run "have you checked the batch is complete", if the user clicks 'yes'
then the report is run, if 'no' then the user is returned to the form.
What I now need is for the report to run with no prompt if the batch is
complete(batch is complete when all records have a value in three fields), if
the batch is not complete then the user is prompted with 'the batch is not
complete do you wish to continue' (YES/NO)
I have tried to run a query that selects the appropriate records and then to
try an if statement in the VBA of the click event of the button, but kept
getting an error message saying 'object required'.
Then turned select query to an append query and put the selected data into a
table and then tried the if then else statement on the table but still
getting the same error message.
Below is the code from the command button on the form. The code may be a
mess as it is a WIP, but any help with direction or with the problems with
the code would be wonderful
Private Sub PrintCert_Click()
On Error GoTo Err_PrintCert_Click
DoCmd.OpenQuery "qrybatchcompletetestforcert", acViewNormal, acReadOnly
DoCmd.OpenTable "tbltestforcert", acViewNormal
DoCmd.Close acQuery, "qrybatchcompletetestforcert"
If Table!tbltestforcert!Expr1 = 1 Then
RetValue = MsgBox("Are you aware the batch is not yet complete?", vbYesNo)
If RetValue = 6 Then
DoCmd.OpenReport "Certificate Details", acPreview
Else
PrintCert.SetFocus
End If
Else
DoCmd.OpenReport "Certificate Details", acViewPreview
End If
Exit_PrintCert_Click:
Exit Sub
Err_PrintCert_Click:
MsgBox Err.Description
Resume Exit_PrintCert_Click
End Sub
I have a form [Sample Results] with a command button which runs a report
"Certificate Details", currently there is a question posed before the report
is run "have you checked the batch is complete", if the user clicks 'yes'
then the report is run, if 'no' then the user is returned to the form.
What I now need is for the report to run with no prompt if the batch is
complete(batch is complete when all records have a value in three fields), if
the batch is not complete then the user is prompted with 'the batch is not
complete do you wish to continue' (YES/NO)
I have tried to run a query that selects the appropriate records and then to
try an if statement in the VBA of the click event of the button, but kept
getting an error message saying 'object required'.
Then turned select query to an append query and put the selected data into a
table and then tried the if then else statement on the table but still
getting the same error message.
Below is the code from the command button on the form. The code may be a
mess as it is a WIP, but any help with direction or with the problems with
the code would be wonderful
Private Sub PrintCert_Click()
On Error GoTo Err_PrintCert_Click
DoCmd.OpenQuery "qrybatchcompletetestforcert", acViewNormal, acReadOnly
DoCmd.OpenTable "tbltestforcert", acViewNormal
DoCmd.Close acQuery, "qrybatchcompletetestforcert"
If Table!tbltestforcert!Expr1 = 1 Then
RetValue = MsgBox("Are you aware the batch is not yet complete?", vbYesNo)
If RetValue = 6 Then
DoCmd.OpenReport "Certificate Details", acPreview
Else
PrintCert.SetFocus
End If
Else
DoCmd.OpenReport "Certificate Details", acViewPreview
End If
Exit_PrintCert_Click:
Exit Sub
Err_PrintCert_Click:
MsgBox Err.Description
Resume Exit_PrintCert_Click
End Sub