Create a button on your form "btnSpell" ... (Titled, "Spell"); specify [event procedure] for event 'On Click'; enter the following VBA code...
Private Sub btnSpell_Click()
On Error GoTo Err_btnSpell_Click
Dim ctlSpell As Control
Set ctlSpell = Screen.PreviousControl
If TypeOf ctlSpell Is TextBox Then
If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then
MsgBox "There is nothing to spell check."
ctlSpell.SetFocus
Exit Sub
End If
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
Else
MsgBox "Spell check is not available for this item."
End If
ctlSpell.SetFocus
Exit_btnSpell_Click:
Exit Sub
Err_btnSpell_Click:
MsgBox "Error " & Err.Number & ":" & Chr$(13) & Chr$(10) & Err.Description
Resume Exit_btnSpell_Click
End Sub
Note... to the best of my knowledge... you cannot spell check all fields on a form at once... the above works when a user has his cursor in any one field on a form... it will only spell check that one field...
|