try the following, as
Private Sub CmdBtnPrint_Deposit_Note__Order__Click()
On Error GoTo Err_CmdBtnPrint_Deposit_Note__Order__Click
Dim stDocName As String
stDocName = "McrDeposit Note"
If Me!Paid Then
DoCmd.RunMacro stDocName
Else
MsgBox "Put your message here, between the double quotes."
End If
Exit_CmdBtnPrint_Deposit_Note__Order__Cl:
Exit Sub
Err_CmdBtnPrint_Deposit_Note__Order__Click:
MsgBox Err.Description
Resume Exit_CmdBtnPrint_Deposit_Note__Order__Cl
End Sub
not sure why you're using a VBA procedure to simply run a macro, though. if
you'd like to learn 1) how to run the macro directly from the command
button, without using VBA at all, or 2) how to run the reports from the VBA
code, without using a macro at all, post back and i'll walk you through
either one.
hth
Oscar50 said:
hi, sorry to sound stupid but i have no experience in VBA.
The command button that i am using is linked to a macro. The macro prints 2
reports out. (The reports are bound to a single query as the 2 reports are
basically the same but have differnet titles). Please could you advise how to
insert the "checking code", the code of the command button is as follows
Private Sub CmdBtnPrint_Deposit_Note__Order__Click()
On Error GoTo Err_CmdBtnPrint_Deposit_Note__Order__Click
Dim stDocName As String
stDocName = "McrDeposit Note"
DoCmd.RunMacro stDocName
Exit_CmdBtnPrint_Deposit_Note__Order__Cl:
Exit Sub
Err_CmdBtnPrint_Deposit_Note__Order__Click:
MsgBox Err.Description
Resume Exit_CmdBtnPrint_Deposit_Note__Order__Cl
End Sub
tina said:
you can't do it within the query. do it with VBA code in the form. if you're
using a command button to open the query (or, much preferrably, a form or
report bound to the query), then put the "checking" code there. for example:
If Me!Paid Then
<put here the code to open the query (or form? report?)>
Else
MsgBox "Put your message here."
End If
hth
i have a criteria in a query for the OrderID to be;
[Forms]![TblOrder]![Order ID]
i want the same query to check another field 'Paid' (the 'Paid' field is a
tick box) to see if its been ticked, if the box is ticked then the query
continues but if the box isnt ticked the query stops and gives a message.
how
do i do this.
Thanks, Oscar.