J
Joe
I am having a problem with a validation rule that is meant to force users to
enter only upper case in cboDiagnosis which has row source qry_diagnosis.
The validation rule is
=StrComp(UCase([Diagnosis]),[Diagnosis],0)=0
An associated On Not In List event procedure in cbo_diagnosis is
Private Sub cboDiagnosis_NotInList(NewData As String, Response As Integer)
On Error GoTo CboDiagnosis_NotInList_Err
Dim intAnswer As Integer
Dim stSQL As String
intAnswer = MsgBox("The Diagnosis " & Chr(34) & Chr(34) & Chr(34) &
NewData & _
Chr(34) & Chr(34) & Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "FBW Physiotherapy")
If intAnswer = vbYes Then
strSQL = "INSERT INTO Diagnosis([Diagnosis]) " & _
"VALUES (""" & NewData & """);"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new Diagnosis has been added to the list." _
, vbInformation, "FBW Physiotherapy"
Response = acDataErrAdded
Else
MsgBox "Please choose a Diagnosis from the list." _
, vbInformation, "FBW Physiotherapy"
Response = acDataErrContinue
End If
CboDiagnosis_NotInList_Exit:
Exit Sub
CboDiagnosis_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume CboDiagnosis_NotInList_Exit
End Sub
On entering lower case data that is not in the list, the user is presented
with the "not in list" error first and then if they click OK to add to list
the data is added as lower case without the validation rule kicking in. What
have I missed here? Do I need some code in Before Update to force the
validation?
Your help is always much appreciated.
enter only upper case in cboDiagnosis which has row source qry_diagnosis.
The validation rule is
=StrComp(UCase([Diagnosis]),[Diagnosis],0)=0
An associated On Not In List event procedure in cbo_diagnosis is
Private Sub cboDiagnosis_NotInList(NewData As String, Response As Integer)
On Error GoTo CboDiagnosis_NotInList_Err
Dim intAnswer As Integer
Dim stSQL As String
intAnswer = MsgBox("The Diagnosis " & Chr(34) & Chr(34) & Chr(34) &
NewData & _
Chr(34) & Chr(34) & Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "FBW Physiotherapy")
If intAnswer = vbYes Then
strSQL = "INSERT INTO Diagnosis([Diagnosis]) " & _
"VALUES (""" & NewData & """);"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new Diagnosis has been added to the list." _
, vbInformation, "FBW Physiotherapy"
Response = acDataErrAdded
Else
MsgBox "Please choose a Diagnosis from the list." _
, vbInformation, "FBW Physiotherapy"
Response = acDataErrContinue
End If
CboDiagnosis_NotInList_Exit:
Exit Sub
CboDiagnosis_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume CboDiagnosis_NotInList_Exit
End Sub
On entering lower case data that is not in the list, the user is presented
with the "not in list" error first and then if they click OK to add to list
the data is added as lower case without the validation rule kicking in. What
have I missed here? Do I need some code in Before Update to force the
validation?
Your help is always much appreciated.