Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Spell Check in Access 2013 subform

Posted on 2014-09-12
12
Medium Priority
?
488 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 85
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 85
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 85
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

963 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