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