Greetings all.
I've stolen/used this code as a spell checker on forms. -
Dim strSpell
-
-
strSpell = myField.Value
-
If IsNull(Len(strSpell)) Or Len(strSpell) = 0 Then
-
Exit Sub
-
End If
-
With myField
-
.SetFocus
-
.SelStart = 0
-
.SelLength = Len(strSpell)
-
End With
-
DoCmd.SetWarnings False
-
DoCmd.RunCommand acCmdSpelling
-
DoCmd.SetWarnings True
-
What I want to do is:
-loop through specific fields in a recordset -log every spelling error (and its associated field) in a table
-display the results in a form
-return a count of the errors found
need help with the bold part.
I did a little reading, but it looks like all DoCmd.RunCommand acCmdSpelling does is launch the equivalent of a the spell checker--which, I don't believe, I can manipulate/capture.
So, how does the spell checker work? I imagine one could write code to capture a string of consecutive characters (i.e. a space before and after) and check that string against some sort of MS Office dictionary.
Any ideas how to do that?
5 5431
Just subscribing, will return later with a possible solution...
zmbd 5,501
Expert Mod 4TB
tetsuo2030:
- Capturing the spellcheck statistics
I haven’t seen a direct method within VBA for doing this; however, at controlled-use-access-spell-check-possible:Post#5 that has a function where in the built in speller is called. Looks like there will need to be some tweaking… so that the code becomes: - Public Function SpellChecker(Calling As Form)
-
Dim ctlSpell As Control
-
Dim Incoming As String, Outgoing As String
-
Dim line1 As Variant
-
'Dim mbResult As Long
-
DoCmd.SetWarnings False
-
Set ctlSpell = Calling.ActiveControl
-
If (ctlSpell.Locked) Then
-
line1 = "Cannot spell check. Field is read-only"
-
SpellChecker = MsgBox(line1, vbOKOnly)
-
Else
-
If Len(ctlSpell) > 0 Then
-
Incoming = ctlSpell
-
With ctlSpell
-
.SetFocus
-
.SelStart = 0
-
.SelLength = Len(ctlSpell)
-
End With
-
DoCmd.RunCommand acCmdSpelling
-
Outgoing = ctlSpell
-
End If
-
' See if any changes were made 09/29/04
-
If (Incoming <> Outgoing) Then
-
' Notify user that changes
-
' were made, if you want to,
-
' or give Bronx cheer
-
End If
-
End If
-
End Function
You could then use the logic at line 23 to collect your stats
Call it from your control as described in the post by using something like this: - Private Sub txtexample_LostFocus()
-
SpellChecker Me
-
End Sub
I'm sure that you can modify it from here to start looping thru the forms collection as an outer loop and then call and loop thru the controls collection on each form.
Otherwise:
To create a custom spell checker would be quite outside of the realm of what we can do to help; however, we can provide specific help with your code should you run into an issue during development.
The basics, of course, would be that you would need some sort of source to compare with the user entries, and then you may need to consider rather you want a literal match or maybe do approximate matching; there are two articles here on Bytes.com that cover two such methods: ngram aproximate string matching levenshtein approximate string matching
Then be prepared for a slow time going.
On Allen Brownes site ( http://allenbrowne.com/links.html) there is a link to an open source spell checker: http://www.pcesoft.com/Access-Spell-...urce-Code.html that you can incorporate into your application. However, I don't think you can capture the statistics with it.
(I see that ADezii has taken an interest and does some of the most interesting coding!)
The concept is to: - Create a Recordset and Loop thru each Field in every Record.
- Pass the Value in each Field along with the Field Name to a Public Function.
- This Public Function will use Automation Code using (Microsoft Word), and invoke Word's Spell Checker to check each Value for misspelling.
- If a misspelling is found, write the Field Name and the misspelled Value to a Results Table.
- Keep a Running Count of the number of misspellings and output that in some manner.
- Set the Record Source of a Form to the Results Table for viewing.
- This is the concept, the implementation of this concept is much more difficult, but I'll see what I can come up with.
I have actually arrived at a rather simple solution using some Excel Automation Code and it's Spell Checking capability. I will post it in its entirety sometime tomorrow. Interesting challenge!
As stated yesterday, I have created a solution that appears to work quite well, but hold on to your seat: - The entire Logic is build around a Table named Table1 with two Fields named Field1 and Field2 but should work equally well with any Table containing any number of Fields and any amount of Records.
-
'Table1 definition
-
Field1 Field2
-
Alpha Marrch
-
Tangoo April
-
Charlie May
-
Foxxtrot June
-
Braavo Jully
-
Zuluu August
-
Dellta September
-
Lima Novemberr
-
- Create an exact Copy of Table1 (structure only) and name it tblResults. This Table will contain the Field Names along with the misspellings.
- Copy-N-Paste the following to a Standard Code Module in order to create a Global 'Instance' of Microsoft Excel.
-
'Create a 'Global' Instance of Microsoft Excel in order to use
-
'its Spell Checking capabilities.
-
Public appExcel As New Excel.Application
- Copy-N-Paste the following Function Definition to a Standard Code Module. This Function will verify each Field Value in every Record to see if it is spelled correctly.
-
Public Function fSpellCheck2(strFieldName As String, strStringToCheck As String) As String
-
'This Function will accept every Field value in every Record and analyze the Field
-
'Values to see if there is a misspelling. If the Value represented by strStringToCheck
-
'is misspelled (CheckSpelling(<strStringToCheck>)=False), write the Field Name as well
-
'as the misspelled Value to a Table (tblResults).
-
If Not appExcel.CheckSpelling(strStringToCheck) Then
-
CurrentDb.Execute "INSERT INTO tblResults ([Field1],[Field2]) VALUES ('" & _
-
strFieldName & "', '" & strStringToCheck & "')", dbFailOnError
-
End If
-
End Function
Copy-N-Paste the Primary Code to any place where it can be executed. This Code will process the Recordset and pass the appropriate Arguments to fSpellCheck2(). - Private Sub Command21_Click()
-
On Error GoTo Err_Command21_Click
-
Dim MyDB As Database
-
Dim rst As DAO.Recordset
-
Dim intNumOfFields As Integer
-
Dim intFldCtr As Integer
-
-
Set MyDB = CurrentDb()
-
Set rst = MyDB.OpenRecordset("Table1", dbOpenForwardOnly)
-
-
'Clear the Results Table by DELETING all existing Records
-
CurrentDb.Execute "DELETE * FROM tblResults", dbFailOnError
-
-
intNumOfFields = rst.Fields.Count
-
-
With rst
-
'Process every single Field in every Record and pass the Field
-
'Name as well as the actual Value to fSpellCheck2() for analysis
-
Do While Not .EOF
-
For intFldCtr = 0 To .Fields.Count - 1
-
Call fSpellCheck2(.Fields(intFldCtr).Name, ![Field1])
-
.MoveNext
-
Next
-
Loop
-
End With
-
-
'The number of Errors (misspellings) will actually be the number
-
'of Records contained within the Results Table (tblResults)
-
MsgBox "Number of Spelling Errors: " & DCount("*", "tblResults")
-
-
'Don't forget to clean up the mess you created, especially with the
-
'Global Object represented by appExcel
-
rst.Close
-
Set rst = Nothing
-
-
appExcel.Quit
-
Set appExcel = Nothing
-
'************************* End of Clean Up ************************
-
-
Exit_Command21_Click:
-
Exit Sub
-
-
Err_Command21_Click:
-
MsgBox Err.Description, vbExclamation, "Error in Command21_Click()"
-
Resume Exit_Command21_Click
-
End Sub
- The results are contained in tblResults and here they are.
- Field1 Field2
-
Field2 Tangoo
-
Field2 Foxxtrot
-
Field1 Braavo
-
Field2 Zuluu
-
Field1 Dellta
- Create a Form and set its Record Source to tblResults to actually view the Results.
- The Code is well commented, but should you have any questions, please feel free to ask.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hank Reed |
last post by:
I am trying to use the spell checker on an unbound control in Access
2000. I run the checker in the AfterUpdate event of the control.
After the spell checker is done, I get the following message:...
|
by: Jason L James |
last post by:
Dear all,
I have an app that captures text entry from
the user and stores it in an SQL DB. I want
to make sure that the text is spelt correctly
using a spell checked; possibly the one...
|
by: Joe |
last post by:
Hello All:
Does anyone know of a spell checker that works with .NET?
Any options will be welcome.
TIA,
--
Joe
|
by: sweetguy1only |
last post by:
Hi all,
I am a MS Access developer using VB 6 (yes, I know it is a bit
old). The problem I am having is, I have a software that allows my
customers to put in the information of their clients....
|
by: Neil |
last post by:
Is there way to have control over the MS-Access spell checking (besides just
launching it)? We want to tell it to check all records, but skip certain
fields (or, alternatively, ONLY check certain...
|
by: Don |
last post by:
I am looking for a C/C++ code spell checker, a tool that checks for
spelling errors in C++ source code. Linux/Unix platforms. Prefer command
line tool. Open source preferred, but will consider...
|
by: ARC |
last post by:
Hello all,
I developed a tool a year or so ago for adding your own spell-checker to an
access application. This is mainly for those using the runtime, as you can't
distribute the spell-checker...
|
by: Mike |
last post by:
I have an app running at a client where, when the spell checker is
supposed to run, it reports "Can't start spell checker because it is
not installed".
I have never had this before - it works...
|
by: farhin |
last post by:
Hi there,
i m developing an application with richtextbox control and asp spell checker control in it.the prblm faced is that Spell check is happening but the change of wrong spelling is not...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |