473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Spell check in subform

tuxalot
200 New Member
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 3317
ADezii
8,834 Recognized Expert Expert
  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 New Member
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 New Member
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
1704
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
3459
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 application icon at the same time. How can I enable the spell check all the time? I saw some code posted by Terry Wickenden in this newsgroup. unfortunately his code didn't work for me.
2
3354
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
10023
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 the data, and since this data is published on their Web site which is their primary interface to their customers, that's a bad thing. I was thinking it would be nice if I could automatically spell check certain fields, and somehow use the Access...
4
10560
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? Thx.
12
5928
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
1721
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 wondering if there was a way to tap into the Word spell check that shows the underlined spelling errors as the person types. If so, can someone point me to some code to try? It would be really nice to show the errors as they type (like word does)...
0
3040
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 the following code to make spell check program on OpenOffice and vb 6.0 it shows error "OBJECT REQUIRED" on line Set vReturn = vSpeller.SPELL(sWord, aLocale, args()) when correct spelling is stored in sWord variable in previous program when a...
0
1593
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 and the current record, from this form, that will then spell check these fields that relate to the comboboxes? This is the code for my spell check button on the form: Private Sub Command18864_Click() RunCommand acCmdSelectRecord RunCommand...
4
3513
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 record. The spell check will not check any of the combo boxes. Private Sub Command18864_Click() RunCommand acCmdSelectRecord
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.