Help With If Statement Please

  • Thread starter Thread starter S Jackson
  • Start date Start date
S

S Jackson

I am trying to build an If Statement. I want a procedure to occur when two
different conditions are met:

If Me.HrgStart = Not Null And Me.HrgOutlook = False Then
. . . .
Else
MsgBox "Deadline Already Added to Outlook"
EndIf

But I find that it is testing for either/or condition and not a combination
of both. For instance, if the HrgStart control is Not Null, and the
Mr.HrgOutlook = False, the procedure will not run, I get the Else procedure.

If the Mr.HrgStart is Null and the HrgOutlook = False, I get the Else
Statement

I cannot get the procedure to run no matter what state the controls are in.

Both conditions have to be true for the procedure to run. If I create the
If statement as such:

If Me.HrgOutlook = False Then
. . . .

I get an error message when the code runs into an empty HrgStart Control.
(The control that contains my date).

Any thoughts?

TIA S. Jackson
 
Shelly,

It is possible for a field to have no data in it but still be considered Not
Null, for example, if there was data previously in the field which was
deleted.

How about ...

If (Not IsNull((Me.HrgStart) or Len(Trim(Me.HrgStart))=0) and Me.HrgOutlook
= False then
 
When you use "Not" it always goes at the front of the statement. Try this:

If Not Me.HrgStart = Null And Me.HrgOutlook = False Then
 
Hi

<anyvariable> = Null evaluates to Null even when <anyvariable> contains
Null.

So the condition Me.HrgStart = Null is not a good test. IsNull() function
should be used.

Immanuel Sibero
 
Back
Top