Form Problem

G

Guest

I have a form that I have two fields I want to show or hide based on the
value in another field. Previously I had one field that worked OK. Recently
I added another field but it is not working.

I have the following in an event but in the Private Sub Form_Current() I am
getting Error '94': Invalid use of Null. Each of the following Me.'s is on a
single line.

Private Sub ExpAcct__AfterUpdate()
Me.[County].Visible = ((Me.[ ExpAcct#] = "93030") Or (Me.[ ExpAcct#] =
"93040"))
Me.[County].Visible = ((Me.[SchoolSystem] = "93030") Or (Me.[SchoolSystem] =
"93040"))
End Sub

Private Sub Form_Current()
Me.[County].Visible = ((Nz(Me.[ExpAcct#], "") = "93030") Or
(Nz(Me.[ExpAcct#], "") = "93040"))
Me.[County].Visible = ((Me.[SchoolSystem] = "93030") Or (Me.[SchoolSystem] =
"93040"))
End Sub

Private Sub RequestedBy_AfterUpdate()
Me.[County].Visible = ((Me.[ExpAcct#] = "93030") Or (Me.[ExpAcct#] = "93040"))
Me.[County].Visible = ((Me.[SchoolSystem] = "93030") Or (Me.[SchoolSystem] =
"93040"))
End Sub

Can anyone tell me what is wrong? I'm a novice at VBA.
Thanks Don
 
D

Douglas J. Steele

It sounds as though one or more of the records have a Null value for
SchoolSystem. You should use the Nz function on that field as well:

Me.[County].Visible = (Nz(Me.[SchoolSystem], vbNullString) = "93030") Or _
(Nz(Me.[SchoolSystem], vbNullString) = "93040")

In fact, I'd recommend using Nz in all 6 lines.
 

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