Spell Check

G

Guest

The function below works for spell check, however it stops when there is a
field Locked, Disabled or Hidden on the form.
Is there a way around this?
***************************************************
Public Function Spell()
Dim ctlSpell As Control
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False
For Each ctlSpell In frm.Controls
If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next
DoCmd.SetWarnings True
End Function
**********************************************************
 
D

Douglas J. Steele

If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
If .Enabled And .Visible And (Not .Locked) Then
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
DoCmd.RunCommand acCmdSpelling
End If
End With
End If
End If
 
G

Guest

Thank you. This sorts the problem. I want to impose on you once more for for
this one. The code does work, but I am just trying to understand it.:

"If TypeOf ctlSpell Is TextBox Then"

What about Memo? I have none locked or disabled on the forms, but If I am
reading the code right, these will not be checked. (They are being checked).

Thanks for your help.
 
A

Arvin Meyer [MVP]

Since I wrote that code about 10 years ago, I can easily answer your
question. A ControlType does not necessarily reflect the field it holds. An
ID field could be displayed in a textbox, a combobox, or a listbox.

Memo fields are invariably displayed in a textbox, so they will be checked
by this code.

It is always a good idea to add the code's author, if known, when you
republish it. In this case, it's me in a post on 9/17/1998 from an
adaptation of code by Terry Wickenden.
 
G

Guest

Thank you for the explanation, and for the spell check function.

The code was not intented to be presented as my own. In my code DB I keep
track of the author to acknowledge if I use or pass it on. This is one I
acquired along the way from, not sure where it came from until now. I have
recorded the author for future refernce. Thanks again.
 

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