473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Spell check in subform

tuxalot
200 100+
I am using this code to perform spell checks (not sure where I got it, but it works a peach):

Expand|Select|Wrap|Line Numbers
  1. Public Function SpellChecker(Calling As Form)
  2.     On Error GoTo Err_SpellChecker
  3.     Dim ctlSpell As Control
  4.     Dim Incoming As String, Outgoing As String
  5.  
  6.     DoCmd.SetWarnings False
  7.  
  8.     Set ctlSpell = Calling.ActiveControl
  9.     If (ctlSpell.Locked) Then
  10.         Line1 = "Cannot spell check. Field is read-only"
  11.         mbResult = MsgBox("OK", "", "", Line1)
  12.     Else
  13.  
  14.         If (ctlSpell) > 0 Then
  15.             Incoming = ctlSpell
  16.             With ctlSpell
  17.                 .SetFocus
  18.                 .SelStart = 0
  19.                 .SelLength = Len(ctlSpell)
  20.             End With
  21.             DoCmd.RunCommand acCmdSpelling
  22.             Outgoing = ctlSpell
  23.         End If
  24.         ' See if any changes were made 09/29/04
  25.         If (Incoming <> Outgoing) Then
  26.             ' Notify user that changes
  27.             ' were made, if you want to,
  28.             ' or give Bronx cheer
  29.         End If
  30.     End If
  31.  
  32.     DoCmd.SetWarnings True
  33.  
  34. exit_SpellChecker:
  35.     Exit Function
  36.  
  37. Err_SpellChecker:
  38.     Select Case Err.Number
  39.         Case 2424
  40.             'MsgBox "change rs"
  41.             Exit Function
  42.         Case 438
  43.             MsgBox "438 error"
  44.         Case Else
  45.             MsgBox Err.Number & "-" & Err.Description
  46.             Resume exit_SpellChecker
  47.     End Select
  48. End Function
  49.  
Setup:

The textboxes that are spell checked reside on a subform that has it's recordsource dynamically created by an option group on the parent form (criteria in query changes by the value of the option group button selected).

Problem:

If a textbox that has focus contains a misspelled word and the option group is clicked, ctlSpell does not exist and it throws a 2424 error. Strangely, I tested this in a textbox that contains properly spelled words and it works fine. No worries here but strange nonetheless.

Question:

Can I fire the spellcheck as part of the option group click event? So in effect the function could complete before the recordsource for the subform is changed. If this might work, how would I pass ctlSpell (the active control prior to clicking the option group) back to the function when the option group has already been clicked? Perhaps there is a better way but my limited knowledge of Access is tapped at the moment.

Thanks for looking and for providing any assistance you can.
Nov 22 '10 #1
3 3287
ADezii
8,834 Expert 8TB
  1. You can Declare a Global Object Variable as Type Control in a Standard Code Module, as in:
    Expand|Select|Wrap|Line Numbers
    1. Public gctlActiveControl As Control
  2. At some point prior to the Option Group Click, assign the Object Variable to the appropriate Control, as in:
    Expand|Select|Wrap|Line Numbers
    1. Set gctlActiveControl = Me![txtTest]
  3. You can then use the With...End With Structure in the traditional manner, as in:
    Expand|Select|Wrap|Line Numbers
    1. With gctlActiveControl
    2.   .SetFocus
    3.   'YaDa-YaDa
    4. End With
Nov 23 '10 #2
tuxalot
200 100+
Thanks for the quick response ADezii. One thing I failed to note is the textbox I wish to spell check resides in a continuous subform, so I think that means that there is only one textbox. I'll give your code a go.

Thanks again.
Nov 23 '10 #3
tuxalot
200 100+
This seems to work in the on click event of the option group:
Expand|Select|Wrap|Line Numbers
  1.     sfrmResponses.SetFocus
  2.     DoCmd.SetWarnings False
  3.     DoCmd.RunCommand acCmdSpelling
  4.     DoCmd.SetWarnings True
  5.     Me.sfrmResponses.Form.RecordSource = "qsfrmSurveyResponses"
  6.     Me.TabCtl.Value = 1
  7.  
I think I was overthinking it. I think.
Nov 23 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jonathan W. Zaleski | last post by:
I was wondering if such a plugin existed outside the Office Bundle, that would preform a spell-check of an indicated field within a HTML Page.
2
by: eddie wang | last post by:
Hello, I inherited an Access application from a previous coworker. It seems the Spell Check is never enabled unless I open the application by holding down the shift key and double clicking the...
2
by: Cassie Pennington | last post by:
Is there a command to spell check fields in Access (probably in the afterupdate event)? Thanks in anticipation Cassie
8
by: Steve Jorgensen | last post by:
There's this app I wrote a long time ago for a client who uses it to administer the database content that drives their Web site. Last time I was in there' I notices a lot of embarassing typos in...
4
by: Vish | last post by:
Is there a way to implement Spell Check Functionality into WinForm (for the text(s) contained/ entered in text box). What are the best ways to implement spell checking in a WinForms application? ...
12
by: Ryan | last post by:
Is there anyway to enable spell-checking for user input in a Text Box? Either auto spell-check or create a spell-check button. Using VB 2005.
3
by: John Wright | last post by:
I have a VB program that will be generating documentation that will be stored for 60 years. This program really needs to have spell check and I read the post below on using spell check. I was...
0
by: progvar | last post by:
hi i am getting probleum in converting a spell check progrma made in vb 6.0 and Ms-office Word into OpenOffice Word when i made spell check program in Ms-Word and vb 6.0 it works fine but i use...
0
by: alnino | last post by:
I have set up a form to autocomplete fields via comboboxes. Unfortunately, my vb code to spell check the current record will not check the comboboxes. Is there a way to call the associated table...
4
by: alnino | last post by:
Hi, I currently have a form that uses combo boxes for user input. The combo boxes function as “autocomplete”. All works fine except for: I have a command button to spell check the current form...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.