Spell check - round two

L

Larry Kahm

My application has a combo box for City names. The client requested spell
check prior to adding a new value. She figures not many people are going to
get "Cincinnati" (sp?) correct no matter what.

So, I tried the following code on the cboCityID_NotInList event:

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

' Check the spelling
With Me.cboCityID
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
' DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
' DoCmd.SetWarnings True

' Set Response argument to indicate that new data is being added.
strSQL = "INSERT INTO tblCities([City]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded

And it seems that I can't get the spell check to run. Access generates the
following error:

"The spelling checker only works on text fields that contain text data
You're trying to check a field with a data type other than Text or Memo."

If anyone has any suggestions, I am willing to listen and learn.

Thanks!

Larry
 
L

Larry Kahm

I thought I would code something to try to get around this issue.

In the NotInList event, I opened a new form (acDialog) and had an unbound
text box filled with the NewData value. I took the spell check code out of
the combo box event and put it on the new form.

The spell check would correct the spelling error, and I was able to pass the
corrected value back to the calling form, but could not find a way to change
the value that was originally in error in the box.

Despite that, the newly corrected value would get entered in the list - but
the old error message was still displayed. Apparently, this part of the
acDataErrAdded definition is coming into play:

"After the entry is added, Microsoft Access updates the list by requerying
the combo box. Microsoft Access then rechecks the string against the combo
box list, and saves the value in the NewData argument in the field the combo
box is bound to. If the string is not in the list, then Microsoft Access
displays an error message."

So, while I spent an hour coding and testing - and came >this< close - I
still don't have a solution.

Anyone with any ideas?

Thanks!

Larry
 
S

soraiaduartes

Larry Kahm said:
I thought I would code something to try to get around this issue.

In the NotInList event, I opened a new form (acDialog) and had an unbound
text box filled with the NewData value. I took the spell check code out
of the combo box event and put it on the new form.

The spell check would correct the spelling error, and I was able to pass
the corrected value back to the calling form, but could not find a way to
change the value that was originally in error in the box.

Despite that, the newly corrected value would get entered in the list -
but the old error message was still displayed. Apparently, this part of
the acDataErrAdded definition is coming into play:

"After the entry is added, Microsoft Access updates the list by requerying
the combo box. Microsoft Access then rechecks the string against the combo
box list, and saves the value in the NewData argument in the field the
combo box is bound to. If the string is not in the list, then Microsoft
Access displays an error message."

So, while I spent an hour coding and testing - and came >this< close - I
still don't have a solution.

Anyone with any ideas?

Thanks!

Larry


Larry Kahm said:
My application has a combo box for City names. The client requested
spell check prior to adding a new value. She figures not many people are
going to get "Cincinnati" (sp?) correct no matter what.

So, I tried the following code on the cboCityID_NotInList event:

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

' Check the spelling
With Me.cboCityID
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
' DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSpelling
' DoCmd.SetWarnings True

' Set Response argument to indicate that new data is being added.
strSQL = "INSERT INTO tblCities([City]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded

And it seems that I can't get the spell check to run. Access generates
the following error:

"The spelling checker only works on text fields that contain text data
You're trying to check a field with a data type other than Text or Memo."

If anyone has any suggestions, I am willing to listen and learn.

Thanks!

Larry
 

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