If statement

G

Guest

I have a form called frm_Vendor, on which I have a subform called
subfrm_Application.

I am trying to write code that says if Vendor_Nbr is 0 and Status_Code =
"Waiting List" (this is on the Vendor form), Application_Request_Date must be
populated on the Application tab (the subform).

I tried this code in the subfrm_Application BeforeUpdate event (and also
tried it on the frm_Vendor Before Updae Event:

If (Parent.Vendor_Nbr = "0" And Parent.Status_Code = "Waiting List" And
IsNull(Me.Application_Request_Date = True)) Then MsgBox "An Application
Request Date is required when Vendor Number is 0."
Cancel = True
End If

This didn't enforce anything. Any ideas on what is wrong with my code or if
I should be placing this in a different location? Thanks!
 
S

SteveS

Hi Lori,

It sounds like the "Application Request Date' is in the subform, so when a new
record is added in the subform, I would think you would want to check the date
in the subform BeforeUpdate event.

You can't check for nulls like you did.

Use

IsNull(Me.Application_Request_Date)

or

Len(IsNull(Me.Application_Request_Date))>0



Also, is [Parent.Vendor_Nbr] a string or a number?
If it is a number you should use:


If (Parent.Vendor_Nbr = 0 And Parent.Status_Code = "Waiting List" And
IsNull(Me.Application_Request_Date) Then

MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End If
 
G

Guest

Thanks Steve! It worked!

SteveS said:
Hi Lori,

It sounds like the "Application Request Date' is in the subform, so when a new
record is added in the subform, I would think you would want to check the date
in the subform BeforeUpdate event.

You can't check for nulls like you did.

Use

IsNull(Me.Application_Request_Date)

or

Len(IsNull(Me.Application_Request_Date))>0



Also, is [Parent.Vendor_Nbr] a string or a number?
If it is a number you should use:


If (Parent.Vendor_Nbr = 0 And Parent.Status_Code = "Waiting List" And
IsNull(Me.Application_Request_Date) Then

MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End If

--
HTH
--
Steve S.
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)
I have a form called frm_Vendor, on which I have a subform called
subfrm_Application.

I am trying to write code that says if Vendor_Nbr is 0 and Status_Code =
"Waiting List" (this is on the Vendor form), Application_Request_Date must be
populated on the Application tab (the subform).

I tried this code in the subfrm_Application BeforeUpdate event (and also
tried it on the frm_Vendor Before Updae Event:

If (Parent.Vendor_Nbr = "0" And Parent.Status_Code = "Waiting List" And
IsNull(Me.Application_Request_Date = True)) Then MsgBox "An Application
Request Date is required when Vendor Number is 0."
Cancel = True
End If

This didn't enforce anything. Any ideas on what is wrong with my code or if
I should be placing this in a different location? Thanks!
 
G

Guest

Wonderful!
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Lori said:
Thanks Steve! It worked!

SteveS said:
Hi Lori,

It sounds like the "Application Request Date' is in the subform, so when a new
record is added in the subform, I would think you would want to check the date
in the subform BeforeUpdate event.

You can't check for nulls like you did.

Use

IsNull(Me.Application_Request_Date)

or

Len(IsNull(Me.Application_Request_Date))>0



Also, is [Parent.Vendor_Nbr] a string or a number?
If it is a number you should use:


If (Parent.Vendor_Nbr = 0 And Parent.Status_Code = "Waiting List" And
IsNull(Me.Application_Request_Date) Then

MsgBox "An Application Request Date is required when Vendor Number is 0."
Cancel = True
End If

--
HTH
--
Steve S.
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)
I have a form called frm_Vendor, on which I have a subform called
subfrm_Application.

I am trying to write code that says if Vendor_Nbr is 0 and Status_Code =
"Waiting List" (this is on the Vendor form), Application_Request_Date must be
populated on the Application tab (the subform).

I tried this code in the subfrm_Application BeforeUpdate event (and also
tried it on the frm_Vendor Before Updae Event:

If (Parent.Vendor_Nbr = "0" And Parent.Status_Code = "Waiting List" And
IsNull(Me.Application_Request_Date = True)) Then MsgBox "An Application
Request Date is required when Vendor Number is 0."
Cancel = True
End If

This didn't enforce anything. Any ideas on what is wrong with my code or if
I should be placing this in a different location? Thanks!
 

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