Code for IF Statement

D

DeVille

I have this piece of code that checks if the [quantity]
text box is filled in on the orders subform before it
allows the user to run a macro to email the order to the
supplier. It works fine however, I would like to add
another condition in the IF segment that says, to also
check the [OrderSent] text box has the text 'Yes' entered
in it

Here is the code I have so far. The question marks
surround the code that I am unsure how to write if any
one could help complete the code thanks in advance

If IsNull(Forms![frmLocations]![subOrders].Form!
[Quantity])
Then
MsgBox "Enter the quantity before sending order."

??? Or IF (Forms![frmLocations]![subOrders].Form!
[OrderSent] = Yes
Then
MsgBox "Order has already been sent." ???

Else

Dim stDocName As String

stDocName = "mcrSendOrders"
DoCmd.RunMacro stDocName

End If
 
G

Guest

Is this what you are looking for

If IsNull(Forms![frmLocations]![subOrders].Form![Quantity]) The
MsgBox "Enter the quantity before sending order.

ElseIf Forms![frmLocations]![subOrders].Form![Quantity] < 1 The
MsgBox "Quantity must be 1 or more.

ElseIf Forms![frmLocations]![subOrders].Form![OrderSent] = True The
MsgBox "Order has already been sent." ??

Els

Dim stDocName As Strin

stDocName = "mcrSendOrders
DoCmd.RunMacro stDocNam

End I


Stev
-------------------------------
"Veni, Vidi, Velcro
(I came; I saw; I stuck around.


----- DeVille wrote: ----

I have this piece of code that checks if the [quantity]
text box is filled in on the orders subform before it
allows the user to run a macro to email the order to the
supplier. It works fine however, I would like to add
another condition in the IF segment that says, to also
check the [OrderSent] text box has the text 'Yes' entered
in it

Here is the code I have so far. The question marks
surround the code that I am unsure how to write if any
one could help complete the code thanks in advance

If IsNull(Forms![frmLocations]![subOrders].Form
[Quantity])
The
MsgBox "Enter the quantity before sending order.

??? Or IF (Forms![frmLocations]![subOrders].Form
[OrderSent] = Yes
The
MsgBox "Order has already been sent." ??

Els

Dim stDocName As Strin

stDocName = "mcrSendOrders
DoCmd.RunMacro stDocNam

End I
 
T

Treebeard

Is the OrdersSent field a boolean or text? If it is text then you need
quotes around the value.


If Not IsNumeric(Forms![frmLocations]![subOrders].Form![Quantity]) Then
MsgBox "Enter the quantity before sending order."

ElseIf Forms![frmLocations]![subOrders].Form![OrderSent] = "Yes" Then
MsgBox "Order has already been sent." ???

Else
 
G

Guest

You're right

I shouldn't have assumed frmLocations]![subOrders].Form![OrderSent] was boolean. It looked like boolean from the example, but.....

Stev
 

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