SelLength not working (1 Viewer)

smig

Registered User.
Local time
Today, 19:03
Joined
Nov 25, 2009
Messages
2,131
SelLength not working is not working for a sub form.
It will select all text

Code:
 me.Materials_SubForm.Form.MaterialDescription.SetFocus
 me.Materials_SubForm.Form.MaterialDescription.SelLength = 0
 

theDBguy

I’m here to help
Local time
Today, 09:03
Joined
Oct 29, 2018
Messages
10,693
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.
 

smig

Registered User.
Local time
Today, 19:03
Joined
Nov 25, 2009
Messages
2,131
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.
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:
 

theDBguy

I’m here to help
Local time
Today, 09:03
Joined
Oct 29, 2018
Messages
10,693
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?
 

smig

Registered User.
Local time
Today, 19:03
Joined
Nov 25, 2009
Messages
2,131
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?
This is the most weird ever :banghead:
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 :eek:
 

moke123

AWF VIP
Local time
Today, 12:03
Joined
Jan 11, 2013
Messages
1,491
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
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
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 12:03
Joined
Jun 20, 2003
Messages
6,370
Code:
 me.Materials_SubForm.Form.MaterialDescription.SetFocus
 me.Materials_SubForm.Form.MaterialDescription.SelLength = 0
Do you not have to set Focus to the Subform Control itself...then to the Control on the Subform?
Code:
 Me.NameOfSubFormControl.SetFocus
 Me. NameOfSubFormControl.Form.ControlName.SetFocus
Linq ;0)>
 

smig

Registered User.
Local time
Today, 19:03
Joined
Nov 25, 2009
Messages
2,131
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
I'm trying to select only part of the text (A text I'm searching for)
 

smig

Registered User.
Local time
Today, 19:03
Joined
Nov 25, 2009
Messages
2,131
Do you not have to set Focus to the Subform Control itself...then to the Control on the Subform?
Code:
 Me.NameOfSubFormControl.SetFocus
 Me. NameOfSubFormControl.Form.ControlName.SetFocus
Linq ;0)>
No it's not that
 

smig

Registered User.
Local time
Today, 19:03
Joined
Nov 25, 2009
Messages
2,131
this code will case an error on the marked line.
If I debug and let the code continue from next line it will select what I need.
If I remove the error causing line (Or any other error causing line) it will select the entire text

Code:
        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))
If I put a MsgBox at the end I can see it select OK, but once I click the msgbox it will select the entire text :eek:
even an Exit Sub just after this won't help :mad:
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom