Spell check A CBO be NotInList Fires

Paul Cooke

Registered User.
Local time
Today, 17:23
Joined
Oct 12, 2001
Messages
288
Hi guys is it possible to spell check a combo box before the NotInlist event triggers?

I have the following code in the event

Code:
Private Sub cboPatientOccupation_NotInList(NewData As String, Response As Integer)
'Checks occuptaion typed in against current records and adds it to table if user selects Yes

Dim intAnswer As Integer
Dim strSql As String

    Beep
    intAnswer = MsgBox("The occupation " & Chr(34) & NewData & Chr(34) & " has not been stored in the database yet." & vbCrLf & _
    "Click Yes to add it to the list or No to choose a occupation from the current list.", vbQuestion + vbYesNo, "New Occupation")
    If intAnswer = vbYes Then
    strSql = "INSERT INTO PatientOccupations([PatientOccupation]) " & "VALUES ('" & StrConv(NewData, vbProperCase) & "');"
    DoCmd.SetWarnings False
    DoCmd.RunSQL strSql
    DoCmd.SetWarnings True
    MsgBox "The new occupation has been added to the database.", vbInformation, "New Data Added"
    Response = acDataErrAdded
    
Else

    MsgBox "Please select an occupation from the list..", vbInformation, "New Data Not Added"
    Response = acDataErrContinue

End If

cboPatientOccupation_NotInList_Exit:
    
Exit Sub

cboPatientOccupation_NotInList_Err:
    MsgBox Err.Description, vbCritical, "Error"
    
Resume cboPatientOccupation_NotInList_Exit

End Sub


I want to try to get it to check the spelling before the users is prompted to add a new occupation to the list so for example if they entered 'nuurse' instead of 'nurse' (which is currently in the table) the spell check would kick in and they can move on with the rest of the form.

The Spell check code i am using is

Code:
        DoCmd.SetWarnings False
        
        If Len(Me!cboPatientOccupation.Column(1) & "") > 0 Then
        DoCmd.RunCommand acCmdSpelling
        
        DoCmd.SetWarnings True
        
        Else
        
        Exit Sub

I have tried putting this on the Afterupdate and at the start of the NotInList events but it does not work - anyone got any suggestions please.

Many thanks
 

Users who are viewing this thread

Back
Top Bottom