Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you Spell check only one records "textbox" field with this command 4

Status
Not open for further replies.

testkitt2

Technical User
Apr 28, 2004
193
US
Hello to all
When creating a new record and getting to the "txtdescription" textbox field the code below is triggered after update..but then after it checks it wants to check the same field for every record...this will take too long. I want to do just the new record or a record I select and that's it.
Code:
DoCmd.RunCommand acCmdSpelling
Thanks
JZ

Testkitt2
 
This will limit the spellcheck to the one field on the current record.


Code:
Private Sub txtDescription_Exit(Cancel As Integer)
With Me!txtDescription
   
  If Len(.Value) > 0 Then
    DoCmd.SetWarnings False
    .SelStart = 1
    .SelLength = Len(.Value)
    DoCmd.RunCommand acCmdSpelling
     .SelLength = 0
    DoCmd.SetWarnings True
  End If

End With

End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
How are ya testkitt2 . . .

As a precursor [blue]you need to highlite what it is you want checked![/blue] . . . otherwise how is the spell checker to know? Hence with nothing hilited it checks all.
Code:
[blue]   DoCmd.RunCommand acCmdSelectRecord
   [green]'Your Code Here[/green][/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
My code checks all data in the text box (txtDescription in the poster's case) that the event is associated with, without having to hilite anything. And it only does it for the current record, which was the OP's requirement.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Howdy missinglinq [thumbsup2] . . .

. . . and what does the following do in [purple]purple[/purple]:
Code:
[blue]With Me!txtDescription
   
  If Len(.Value) > 0 Then
    DoCmd.SetWarnings False
    [purple][b].SelStart = 1
    .SelLength = Len(.Value)[/b][/purple] '[green]Hilite occurs here![/green]
    DoCmd.RunCommand acCmdSpelling
     [purple][b].SelLength = 0[/b][/purple] [green]'Remove Hilite[/green]
    DoCmd.SetWarnings True
  End If

End With[/blue]
Also:
testkitt2 said:
[blue]I want to do just the new record or a record I select and that's it.[/blue]
I agree with the ambiguity but my post covers checking the current record (the other half of the ambiguity) . . . As search goes throughtout office, in code, if you don't hilite what ya want [blue]all is checked![/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
You're right, as usual! Wasn't thinking!

Have a great Memorial Day!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Hello Ms.missinglinq
And thank you for your answer to my post.
TheAceMan1 nice to hear from you..its been a while..but you have always come thru for me in a crunch.

I don't want to have to highlight a word or a sentence to have spell check do its thing. I basically want it to look at that field in its entirety after that field is done with.
I have two users at work who use this DB beside myself and their spelling is blahhhh.... need I say more.
So if I purchased a pair of brake shoes for the shop.. and end up with this sentence....a pair of "brake sheos for hte sohp" after hitting enter and before going to the next field ..good old spell check pops up.
I have yet to try Ms.missinglinq suggestion..but I will right about now...
Hey.. again big thanks to you guys for taking the time.
JZ

Testkitt2
 
testkitt2 . . .

According to your latest . . . indeed try the code provided by [blue]missinglinq[/blue]. If you take a look at my rendition of the code you'll see where the hiliting occurs.

You don't have to hilite, but to narrow the search to the textbox only . . . all its text has to be hilited. If you look at the code by [blue]missinglinq[/blue] you'll see where its turned on, spell checking done, and then turned off! . . . [blue]AKA the hiliting is simply done it code![/blue]

[blue]Can you see it! . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Hey good late night to all.
I tried the code suggested by missinglinq and It look like it was working but then I go the error messager below.

The macro of function set to the beforeupdate or validationrule property for his field is preventing JZ POlog from saving the data in this field.

Thanks again
JZ

Testkitt2
 
The macro of function set to the beforeupdate or validationrule property for his field is preventing JZ POlog from saving the data in this field."

Where did you place my code? We need to see the entire code for the sub where you placed it. The above error usually refers, in my experience, to something placed in the BeforeUpdate sub for an object. Code in the YourTextBox_Exit sub shouldn't produce this!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 

As a slight aside, AceMan: I'm trying to help someone on another forum who wants to Spell Check only on the current record, but wants to check all text controls on the record. I'm using the code below to loop thru the controls and spell check, but I can't figure out where to put the code! To test it, I'm making the record dirty then trying to move to another record.

If I put it in Form_BeforeUpdate, it Spell Checks but doesn't move to the next record. If I try to leave the record again, it runs Spell Check again.

If I place it in Form_BeforeInsert it does nothing.

Placed in Form_AfterUpdate, it runs Spell Check but doesn't leave the record. You have to click on the navigation button a second time to move.

Code:
For Each ctrl In Me.Controls

    If TypeOf ctrl Is TextBox Then
      
         With ctrl
   
          If Len(.Value) > 0 Then
            DoCmd.SetWarnings False
            .SetFocus
            .SelStart = 1
            .SelLength = Len(.Value)
            DoCmd.RunCommand acCmdSpelling
            .SelLength = 0
            DoCmd.SetWarnings True
          End If

       End With

     
    End If
Next

Any ideas?

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Actually, in thinking about it
Code:
 DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSpelling
will limit the check to the current record, but once again, where to put it? It's behavior is identical to the behavior of my previous code.


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
testkitt2 . . .

I've already done some testing and [blue]missinglinq's[/blue] proir post is correct! . . . (where to place the code?)
TheAceMan1 said:
[blue]The main problem is that events which could be used for automation (BeforeUpdate, AfterUpdate, OnExit, On LostFocus) are in conflict with the spellchecker as [purple]access wants to save while the spellchecker wants to edit! . . . [/purple]Hence errors are raised![/blue]
This eliminates these events and hence your direct automation.

If you don't mind semi-auto control the closet you can get is the [blue]DoubleClick[/blue] event of a [blue]textbox[/blue] to spellcheck the textbox and/or the [blue]DoubleClick[/blue] event of the [blue]form[/blue] to spellcheck a selected record (doubleclicking the record selector). If you decide to persue this method, perform the following:
[ol][li][blue]Backup then delete all previous code[/blue] you have relating to spellchecking . . . [purple]Be sure you get it all![/purple] . . . [purple]We can't afford any interaction here![/purple][/li]
[li]In a [blue]module[/blue] in the [blue]modules window[/blue], copy/paste the following:
Code:
[blue]Public Sub SpellCheck(Optional ctl)
   Dim flg As Boolean
   
   If IsMissing(ctl) Then
      DoCmd.RunCommand acCmdSelectRecord
      flg = True
   ElseIf ctl.ControlType = acTextBox Then
      If Trim(ctl & "") = "" Then
         MsgBox "There is nothing to spell check for " & ctl.Name
      Else
          ctl.SelStart = 0
          ctl.SelLength = Len(ctl)
          flg = True
      End If
   Else
     MsgBox "Spell check is not available for this item."
   End If
   
   If flg Then DoCmd.RunCommand acCmdSpelling
   
End Sub[/blue]
The routine will spellcheck the current record or textbox [blue]depending wether the textbox control is passed![/blue][/li]
[li]For any textbox in the form you desire to individually spellcheck, copy/paste the following to the [blue]DoubleClick[/blue] event of that textbox:
Code:
[blue]   Call SpellCheck(Me![purple][b][i]TextboxName[/i][/b][/purple])[/blue]
[/li]
[li]Finally to cover [blue]selected record[/blue], in the forms [blue]DoubleClick[/blue] event, copy/paste the following:
Code:
[blue]   Call SpellCheck[/blue]
[/li][/ol]
[blue]Special Note: Not only does this method work form any form, it works with subforms as well![/blue] [thumbsup2]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Hello folks,
missinglinq,TheAceMan1
To answer your question I first put the code in the "After Update event"....got that msg....then I made it a function...still got that msg...

but quess what...
missinglinq I tried your suggested code below and you hit the nail on the head....
Code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSpelling

it does exactly..what I want it to do ..you see the only place where one of the DB users could screw up is in the description field, all other fields are drop downs and...etc...
Hey like always..
Many thanks to you guys

****
Hey AceMan1... Good to hear from you.... Hey keep me in mind when I post..
JZ


Testkitt2
 
Nice hack, AceMan!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top