Try adding SelStart=1.
Okay, "not working" means what, exactly? Did you get an error? Can you post a sample copy of your db? It might be faster to figure out what you're trying to do, if we could see it.Not working
Okay, "not working" means what, exactly? Did you get an error? Can you post a sample copy of your db? It might be faster to figure out what you're trying to do, if we could see it.
Okay, if a subform is involved here, then it may be a matter of using the correct syntax. Can you post a sample copy of your db, so we can tell you what syntax you could use?It means it select all text
it work OK if the Text box is on the main form, but not on a sub form :banghead:
Okay, if a subform is involved here, then it may be a matter of using the correct syntax. Can you post a sample copy of your db, so we can tell you what syntax you could use?
If i cause an error by not moving the focus to that txtBox and then debug and move the focus there and let the code continue to run it will select what I'm looking for.
If I let the code run as it should (move the focus to that txtBox) and then try to select what I want it will select the entire text
me.yoursubform.form.textboxname.setfocus
me.yoursubform.form.textboxname.SelStart = 0 ' or whatever place you want to start
me.yoursubform.form.textboxname.SelLength = len(me.yoursubform.form.textboxname) ' or whatever length you want
Code:me.Materials_SubForm.Form.MaterialDescription.SetFocus me.Materials_SubForm.Form.MaterialDescription.SelLength = 0
Me.NameOfSubFormControl.SetFocus
Me. NameOfSubFormControl.Form.ControlName.SetFocus
What exactly are you trying to select if not the entire text?
Is there more code than what you have shown?
provided you have the proper reference and can set the focus to the textbox
try something like
Code:me.yoursubform.form.textboxname.setfocus me.yoursubform.form.textboxname.SelStart = 0 ' or whatever place you want to start me.yoursubform.form.textboxname.SelLength = len(me.yoursubform.form.textboxname) ' or whatever length you want
Hi. Are you not able to post a demo copy of your db?I'm trying to select only part of the text (A text I'm searching for)
No it's not thatDo you not have to set Focus to the Subform Control itself...then to the Control on the Subform?
Linq ;0)>Code:Me.NameOfSubFormControl.SetFocus Me. NameOfSubFormControl.Form.ControlName.SetFocus
Me.MaterialName.SetFocus
Me.MaterialName.SelLength = 0
Call MaterialsFormTabsClicks(1)
[B]Me.Materials_SubForm.Form.SetFocus[/B]
Me.Materials_SubForm.Form.MaterialDescription.SetFocus
Me.Materials_SubForm.Form.MaterialDescription.SelStart = InStr(Me.Materials_SubForm.Form.MaterialDescription.Value, strSearchSplit(0)) - 1
Me.Materials_SubForm.Form.MaterialDescription.SelLength = Len(strSearchSplit(0))