spell check a form

D

deb

I know that f7 spell checks in the forms, but how do I
set the form so it will only spell check the current
record, and not every record I have for that form?
 
S

StCyrM

Hi Deb

To spell check the current field/current record you can use the following
function:

Private Sub cmdSpell_Click()
On Error Resume Next

Dim ctlSpell As Control

' Check the spelling in the selected text box
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

End Sub

------------ OR ---------

To spell check all fields current record, you can use the following:

Dim i As Integer
'Turning off warnings to prevent completion message after each control
is
checked
DoCmd.SetWarnings False
'Loop through each control on the form
For i = 0 To Me.Count - 1
'Check to see if the control is a textbox
If TypeOf Me(i) Is TextBox Then
'Verify that focus is set to the control
Me(i).SetFocus
'Select starting point and select the contents of the control
Me(i).SelStart = 0
'Verify that the control contains data and select the contents
If Len(Me(i)) > 0 Then
Me(i).SelLength = Len(Me(i))
'Run the Spell Checker on the contents of the control
RunCommand acCmdSpelling
End If
End If
Next i
'Tell user that the check is complete for this record.
MsgBox "Spell Check is Complete"
'Turning warnings back on
DoCmd.SetWarnings True


Hope this helps


Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top