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 Programming / July 2005

Tip: Looking for answers? Try searching our database.

Null Value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 03 Jul 2005 19:41 GMT
I have code in a combobox AfterUpdate that I want to update a yes/no field if
the user enters certain values in the Diagnoses field. The problem I am
having is if the user makes a mistake and deletes the value He/She chose in
the combobox creating a null value, I get an error "Runtime error 94",
"Invalid use of Null".

I have tried several ways to fix this but none are working. The following is
the code:

Private Sub Diagnoses_AfterUpdate()

Dim stDiagnosesName As String
   
stDiagnosesName = [Diagnoses]

   If stDiagnosesName = "Diabetes" Then
   CronicCare = "Yes"

   ElseIf stDiagnosesName = "Hypertension" Then
   CronicCare = "Yes"
   
   ElseIf stDiagnosesName = "Seizure Disorder" Then
   CronicCare = "Yes"
   
   ElseIf stDiagnosesName = "Asthma/COPD" Then
   CronicCare = "Yes"
   
   ElseIf stDiagnosesName = "Dialysis" Then
   CronicCare = "Yes"

   Else: CronicCare = "No"
End If
End Sub

How can I fix this problem?

Thanks,

Dennis
Rick Brandt - 03 Jul 2005 19:49 GMT
> I have code in a combobox AfterUpdate that I want to update a yes/no
> field if the user enters certain values in the Diagnoses field. The
> problem I am having is if the user makes a mistake and deletes the
> value He/She chose in the combobox creating a null value, I get an
> error "Runtime error 94", "Invalid use of Null".

You can't assign Null to a String variable.  Instead use...

stDiagnosesName = Nz([Diagnoses],"")

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Don - 03 Jul 2005 21:56 GMT
Rick,

Your solution worked well.
Signature

Thanks,

Dennis

> > I have code in a combobox AfterUpdate that I want to update a yes/no
> > field if the user enters certain values in the Diagnoses field. The
[quoted text clipped - 5 lines]
>
> stDiagnosesName = Nz([Diagnoses],"")
Allan Murphy - 04 Jul 2005 07:33 GMT
Dennis

Just a comment, instead of using the IF statements consider using the CASE
statement. Access has limit to how many level of IFs that it can handles

--
Allan Murphy
Email: allanmurphy@unwired.com.au

> I have code in a combobox AfterUpdate that I want to update a yes/no field if
> the user enters certain values in the Diagnoses field. The problem I am
[quoted text clipped - 35 lines]
>
> Dennis
 
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.