Solved

Spell Check in Access 2013 subform

Posted on 2014-09-12
12
406 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
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
 

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DSum for Access 6 47
Run Time Error 3071 26 40
selection of current record jumps to a non-selected record 8 38
Export Query data to excel file 14 38
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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 …

863 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

19 Experts available now in Live!

Get 1:1 Help Now