If IsNull Statement

G

Guest

I'm trying to write an "If" statement using the "IsNull" function but I'm
stuck on how to write this. What I'm trying to do is write this code to say
if a field is blank do nothing and if a field has data then do the
"SendObject" function. This is being put in the "AfterUpdate" event on a
certain field.
 
G

Guest

Hi Susan,

I understand that part but if I only want to do something if there is data
how do I write that? If it's null then I don't want it to do anything. Only
if it's not null.

SusanV said:
If IsNull([YourField] Then
'do something
else
'do something else
end if
--
hth,
SusanV


Secret Squirrel said:
I'm trying to write an "If" statement using the "IsNull" function but I'm
stuck on how to write this. What I'm trying to do is write this code to
say
if a field is blank do nothing and if a field has data then do the
"SendObject" function. This is being put in the "AfterUpdate" event on a
certain field.
 
J

Jeff Boyce

Pardon my intrusion...

SusanV provided an example of how you could do that.

If you only wish to do something when YourField is not null, put that thing
you want to do after the "Else" statement.

--
Regards

Jeff Boyce
<Office/Access MVP>

Secret Squirrel said:
Hi Susan,

I understand that part but if I only want to do something if there is data
how do I write that? If it's null then I don't want it to do anything. Only
if it's not null.

SusanV said:
If IsNull([YourField] Then
'do something
else
'do something else
end if
--
hth,
SusanV


Secret Squirrel said:
I'm trying to write an "If" statement using the "IsNull" function but I'm
stuck on how to write this. What I'm trying to do is write this code to
say
if a field is blank do nothing and if a field has data then do the
"SendObject" function. This is being put in the "AfterUpdate" event on a
certain field.
 
S

SusanV

For example, I want to view a report called "MyReport" ONLY if "MyField" is
NOT Null:

Sub MyButton_OnClick()
If NOT IsNull([MyField]) Then
DoCmd.OpenReport "MyReport", acViewPreview
End If
End Sub

In the above example, if MyField is Null nothing will happen. Without an
Else clause, the code will simply continue to the next line, in this case,
End Sub

If I want it to open "MyReport if the field IS Null:

Sub MyButton_OnClick()
If IsNull([MyField]) Then
DoCmd.OpenReport "MyReport", acViewPreview
End If
End Sub


Perhaps that is clearer...


Jeff Boyce said:
Pardon my intrusion...

SusanV provided an example of how you could do that.

If you only wish to do something when YourField is not null, put that
thing
you want to do after the "Else" statement.

--
Regards

Jeff Boyce
<Office/Access MVP>

Secret Squirrel said:
Hi Susan,

I understand that part but if I only want to do something if there is
data
how do I write that? If it's null then I don't want it to do anything. Only
if it's not null.

SusanV said:
If IsNull([YourField] Then
'do something
else
'do something else
end if
--
hth,
SusanV


message I'm trying to write an "If" statement using the "IsNull" function but I'm
stuck on how to write this. What I'm trying to do is write this code to
say
if a field is blank do nothing and if a field has data then do the
"SendObject" function. This is being put in the "AfterUpdate" event
on a
certain field.
 
G

Guest

I understand now. Thank you both!

Jeff Boyce said:
Pardon my intrusion...

SusanV provided an example of how you could do that.

If you only wish to do something when YourField is not null, put that thing
you want to do after the "Else" statement.

--
Regards

Jeff Boyce
<Office/Access MVP>

Secret Squirrel said:
Hi Susan,

I understand that part but if I only want to do something if there is data
how do I write that? If it's null then I don't want it to do anything. Only
if it's not null.

SusanV said:
If IsNull([YourField] Then
'do something
else
'do something else
end if
--
hth,
SusanV


message I'm trying to write an "If" statement using the "IsNull" function but I'm
stuck on how to write this. What I'm trying to do is write this code to
say
if a field is blank do nothing and if a field has data then do the
"SendObject" function. This is being put in the "AfterUpdate" event on a
certain field.
 
S

SusanV

Glad to help

Secret Squirrel said:
I understand now. Thank you both!

Jeff Boyce said:
Pardon my intrusion...

SusanV provided an example of how you could do that.

If you only wish to do something when YourField is not null, put that
thing
you want to do after the "Else" statement.

--
Regards

Jeff Boyce
<Office/Access MVP>

Secret Squirrel said:
Hi Susan,

I understand that part but if I only want to do something if there is
data
how do I write that? If it's null then I don't want it to do anything. Only
if it's not null.

:

If IsNull([YourField] Then
'do something
else
'do something else
end if
--
hth,
SusanV


message I'm trying to write an "If" statement using the "IsNull" function
but I'm
stuck on how to write this. What I'm trying to do is write this
code to
say
if a field is blank do nothing and if a field has data then do the
"SendObject" function. This is being put in the "AfterUpdate" event
on a
certain field.
 

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