Spell Check Memo Code NOT Working, Need Help

D

Dave Elliott

Cant seem to make this code work. It just gives me the message Spell check
is not available for this item
It is on a Memo field.





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
 
D

Dirk Goldgar

Dave Elliott said:
Cant seem to make this code work. It just gives me the message Spell check
is not available for this item
It is on a Memo field.





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

How are you triggering this code? What event is it in, and what control is
that event attached to?
 
D

Dave Elliott

It is being triggered using the Double Click Event. The field is a memo
field and the name of the control is Job and actual control name is Job
Description.
 
D

Dirk Goldgar

Dave Elliott said:
It is being triggered using the Double Click Event. The field is a memo
field and the name of the control is Job and actual control name is Job
Description.

The DblClick event of what? Of the text box itself? Reading it over, it
looks to me like that code is meant to be executed from some other control,
like the Click event of a command button. It's trying to spell-check the
control that *previously* had the focus. I don't know what you mean by "the
name of the control is Job and actual control name is Job Description", but
I guess you mean that the control is named "Job" and it's bound to a field
named "Job Description". If that is the case, try this modification of the
code:

'----- start of revised code -----
Private Sub Job_DblClick(Cancel As Integer)

On Error GoTo Err_Handler

Dim ctlSpell As Control

' Check the spelling in the selected text box

With Me!Job
If Len(.Value & vbNullString) = 0 Then
MsgBox "There is nothing to spell check."
Else
.SelStart = 0
.SelLength = Len(ctlSpell)
DoCmd.RunCommand acCmdSpelling
End If
End With

Exit_Point:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error " & Err.Number
Resume Exit_Point

End Sub
'----- end of revised code -----

If I've got the name of the control wrong, then you need to change the name
of the procedure and the "With Me!Job" line.
 

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