Solved

Spell Check in Access 2013 subform

Posted on 2014-09-12
12
401 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
  • 8
  • 4
12 Comments
 
LVL 84
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:dgravitt
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:dgravitt
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for working through this.
0
 
LVL 84
Comment Utility
Thanks - and yes, my avatar is the traditional Block C logo for the mighty South Carolina Gamecocks!!!
0
 

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now