creating critera that checks a input box

G

Guest

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.
 
T

tina

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
 
G

Guest

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


Oscar50 said:
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.
 
T

tina

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


Oscar50 said:
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.
 
G

Guest

Hi Tina!
i have just tried the VBA code you suggested and it works perfectly. Just to
clear up your question 'not sure why you're using a VBA procedure to simply
run a macro'. i created the command button by using the wizard and selecting
the options 'Miscellaneous' and 'Run Macro', i then got the code from the
command button that was created, hope what i have just said makes sense!

Thanks for all your help!!!!!
Oscar

tina said:
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.
 
T

tina

you're welcome :)


Oscar50 said:
Hi Tina!
i have just tried the VBA code you suggested and it works perfectly. Just to
clear up your question 'not sure why you're using a VBA procedure to simply
run a macro'. i created the command button by using the wizard and selecting
the options 'Miscellaneous' and 'Run Macro', i then got the code from the
command button that was created, hope what i have just said makes sense!

Thanks for all your help!!!!!
Oscar

tina said:
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



:

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top