Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / September 2007

Tip: Looking for answers? Try searching our database.

Form Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don S. - 11 Sep 2007 16:00 GMT
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
Douglas J. Steele - 11 Sep 2007 16:25 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>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.
[quoted text clipped - 33 lines]
> Can anyone tell me what is wrong?  I'm a novice at VBA.
> Thanks Don
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.