Isnull with a filter problem

  • Thread starter Thread starter golfinray
  • Start date Start date
G

golfinray

I have a form I use to look up projects for school districts. Each project
has a project number, like 0709-1104-001. Some districts have no projects. If
I open the form to a district with no projects, using my filter, the form is
blank. So I tried:
If IsNull(me.[project number])=true then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

It does not work and I've tried several things. What am I doing wrong?
Thanks, a bunch for your help.
 
Sometimes it helps if you test for "" as well so try adjusting your code to:

If IsNull(me.[project number]) or me.[project number]="" then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

hth
 
Or more efficiently,

If Len(me.[project number] & vbNullString) = 0 then


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Maurice said:
Sometimes it helps if you test for "" as well so try adjusting your code
to:

If IsNull(me.[project number]) or me.[project number]="" then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

hth
--
Maurice Ausum


golfinray said:
I have a form I use to look up projects for school districts. Each
project
has a project number, like 0709-1104-001. Some districts have no
projects. If
I open the form to a district with no projects, using my filter, the form
is
blank. So I tried:
If IsNull(me.[project number])=true then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

It does not work and I've tried several things. What am I doing wrong?
Thanks, a bunch for your help.
 
Thanks Doug - I get no errors, but it won't pop up my msgbox for anything.
Any ideas you or Maurice? Thanks guys!!!

Douglas J. Steele said:
Or more efficiently,

If Len(me.[project number] & vbNullString) = 0 then


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Maurice said:
Sometimes it helps if you test for "" as well so try adjusting your code
to:

If IsNull(me.[project number]) or me.[project number]="" then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

hth
--
Maurice Ausum


golfinray said:
I have a form I use to look up projects for school districts. Each
project
has a project number, like 0709-1104-001. Some districts have no
projects. If
I open the form to a district with no projects, using my filter, the form
is
blank. So I tried:
If IsNull(me.[project number])=true then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

It does not work and I've tried several things. What am I doing wrong?
Thanks, a bunch for your help.
 
Weird, I'm assuming you did step through the procedure and tested to see if
the value was actually null or "". Do you reset the filter after the filter
is applied in a situation where there is a value? Just to make sure the
procedure does what it should do add a textbox and apply the same test as
with the current procedure but leave the else statement out. If that works
you might come to the conclusion that the filter is still bugging it.
--
Maurice Ausum


golfinray said:
Thanks Doug - I get no errors, but it won't pop up my msgbox for anything.
Any ideas you or Maurice? Thanks guys!!!

Douglas J. Steele said:
Or more efficiently,

If Len(me.[project number] & vbNullString) = 0 then


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Maurice said:
Sometimes it helps if you test for "" as well so try adjusting your code
to:

If IsNull(me.[project number]) or me.[project number]="" then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

hth
--
Maurice Ausum


:

I have a form I use to look up projects for school districts. Each
project
has a project number, like 0709-1104-001. Some districts have no
projects. If
I open the form to a district with no projects, using my filter, the form
is
blank. So I tried:
If IsNull(me.[project number])=true then
msgbox "that district has no projects, select another"
else
Me.filter = "[district name] = """ & me.combo & """"
Me.filteron = true
End If
End sub

It does not work and I've tried several things. What am I doing wrong?
Thanks, a bunch for your help.
 
Back
Top