Isnull with a filter problem

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.
 
M

Maurice

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
 
D

Douglas J. Steele

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.
 
G

golfinray

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.
 
M

Maurice

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.
 

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

Similar Threads

Form Filter question 1
Help Please 6
Stuck on filter, help Please 3
Combo Code Help Please 3
Query Help 3
Dirk Goldgar help please!!! 2
sql query won't work 3
Ranking question 3

Top