1
votes

I have created an Access Database which contains all patients from our private healthcare who have had appointments booked in the past year.

The database contains fields such as 'patient ID, Name, Date, Value etc.".

In the value field, some patients have notes such as 'Mental health' or 'Broken Bone'. I have created a function in Access which substitutes a word in the Value field with something else. For example, with Mental Health i would change it to Depression.

Option Compare Database

Option Explicit

Public Function MapDiagnosis( _ strDiagnosis As String) _ As String 'map diagnosis to friendly name If InStr(strDiagnosis, "Mental Health") > 0 Then MapDiagnosis = "depression" Else If InStr(strDiagnosis, "Gyneacological") > 0 Then MapDiagnosis = "pregnant" Else

    MapDiagnosis = "other"
If InStr(strDiagnosis, "Gastritis") > 0 Then
    MapDiagnosis = "indigestion"
Else

If InStr(strDiagnosis, "Muscular") > 0 Then
    MapDiagnosis = "muscle pain"
Else

If InStr(strDiagnosis, "Cardiovascular") > 0 Then
    MapDiagnosis = "heart"
Else

If InStr(strDiagnosis, "Broken Bones") > 0 Then
    MapDiagnosis = "Fracture"
Else

If InStr(strDiagnosis, "No underlying cause") > 0 Then
    MapDiagnosis = "None"

End If

End If

End If

End If

End If

End If

End If

What I don't know how to do is run the script on the 'Immediate' window on VBA which allows me to determine if the words will change.

The script is below.

?MapDiagnosis(strDiagnosis) = "Mental Health"

I'm not sure why the above script is not running on the immediate window.

Any suggestions?

1
Try ?MapDiagnosis("Mental Health") - Gord Thompson
AWESOME!! Works perfectly thanks @GordThompson - Blue
@GordThompson please see my comment under my answer. - WestAce

1 Answers

1
votes

Type:

?MapDiagnosis("Mental Health") 

Into the Immediate window.