Solved

Spell Check in Access 2013 subform

Posted on 2014-09-12
12
433 Views
Last Modified: 2014-09-12
I'm using the code below to spell a field in a subform, it fails at .SelStart = 0, it does pull the characters from the text field for checking. It works in the main form.

If Len(Me!Text14 & "") > 0 Then
        With Me!Text14
            .SetFocus
            .SelStart = 0
            .SelLength = Len(Me!Text14)
        End With
        DoCmd.SetWarnings False
        DoCmd.RunCommand acCmdSpelling
        DoCmd.SetWarnings True
    End If
0
Comment
Question by:dgravitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
12 Comments
 
LVL 84
ID: 40319140
Are you certain Text14 is the name of the Textbox (more on that later)? If so, you might try this:

If Len(Me.Text14 & "") > 0 Then
        With Me.Text14
            .SetFocus
            .SelStart = 0
            .SelLength = Len(Me.Text14)
        End With
        DoCmd.SetWarnings False
        DoCmd.RunCommand acCmdSpelling
        DoCmd.SetWarnings True
    End If

Open in new window

Basically, I've changed the ! to a . instead. Better yet, change the name of that Textbox to something meaningful, like "txCustomerName", and you will be sure that you're referring to the correct value.

Also, regarding Subforms - is this code running in the Mainform, or in the Subform? If it's running in the Mainform, and if you're trying to execute it against objects in the Subform, you'll have to change the textbox reference.

Regarding nameing: You really, really, really should adopt a Nameing Convention for your programming. There are several concepts out there, but essentially you should give meaningful names to all objects, and you should preface those names with a 1 to 3 character tag that indicates the "type" of object they are. For example, "txCustomerName" indicates the control holds the Customer's Name, and that it's most likely a textbox. "cboCustomerType" would indicate the control holds the Type of Customer, and is most likely a Combobox. Doesn't really matter what sort of nomenclature you use, so long as you're consistent, and it makes sense to you.
0
 

Author Comment

by:dgravitt
ID: 40319162
I changed the ! to a .  Still fails at the same point. I included a stop in the code so I could verify the the value being checked is correct. I am checking in the subform. The way I have this setup is, I have an "entry" section in the header. When all fields are filled in, the user clicks add, and then it show in the list in the Detail section. I'm Spell Checking a field in the header on exit from the field.
0
 
LVL 84
ID: 40319331
So is the code you're showing running in an event on the MAIN form, or on the SUBform?

If it's on the MAIN form, then you'll have to refer to the controls on the SUBform differently. For example, if Text14 is on the SUBForm, and you're running the code on the MAIN form:

If Len(Me.YourSubformCONTROL.Form!Text14 & "") > 0 Then
        With Me.YourSubformCONTROL.Form!Text14
            .SetFocus
            .SelStart = 0
            .SelLength = Len(Me.YourSubformCONTROL.Form.Text14)
        End With
        DoCmd.SetWarnings False
        DoCmd.RunCommand acCmdSpelling
        DoCmd.SetWarnings True
    End If

Open in new window

Note that YourSubformCONTROL is the Subform Control on the main form, and may or may not be named the same as the Form you're using as a Subform. To get the name of the control, click ONCE in the subform, then look at the Properties of the object. It should say "Subform/Subreport" in the Properties sheet.

Subform
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:dgravitt
ID: 40319367
Yes, it is running in the subform. I tried the above and get an error on finding the field. Does it matter that this is an unbound field? As stated previously, when I run it the way it was with a Stop in the code, I can verify that it has captured the data in the text box, it just doesn't process it.
0
 

Author Comment

by:dgravitt
ID: 40319377
this is a shot of my form(s). I'm trying to check the desription field at top of the subform.
screen.jpg
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40319479
Does it matter that this is an unbound field?
It might.

When you use SelStart and SelLength, does the text in that control get the Focus, and is it highlighted?
0
 

Author Comment

by:dgravitt
ID: 40319489
That is where the error happens is on SelStart. Sorry, but I must ask about your Icon, is that South Carolina?
0
 

Author Comment

by:dgravitt
ID: 40319511
OK, it is the unbound field. When I move it down to the Detail part and set it on the description field it works. How can I make it check on the add record? I tried it on After Update, but that doesn't work in insert.
0
 

Author Comment

by:dgravitt
ID: 40319521
Got it. I added the check spelling to event procedure after running the insert. I'm going to give you credit because your answers where very thought provoking.
0
 

Author Closing Comment

by:dgravitt
ID: 40319523
Thanks for working through this.
0
 
LVL 84
ID: 40320266
Thanks - and yes, my avatar is the traditional Block C logo for the mighty South Carolina Gamecocks!!!
0
 

Author Comment

by:dgravitt
ID: 40320344
I will be a huge Gamecock fan this weekend. I'm GA Tech. Thanks again for your help.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question