Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-09-2019, 11:38 AM   #1
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
SelLength not working

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

smig is offline   Reply With Quote
Old 12-09-2019, 11:41 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 7,249
Thanks: 63
Thanked 1,681 Times in 1,636 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: SelLength not working

Try adding SelStart=1.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 12-09-2019, 01:35 PM   #3
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: SelLength not working

Quote:
Originally Posted by theDBguy View Post
Try adding SelStart=1.
Not working

smig is offline   Reply With Quote
Old 12-09-2019, 01:44 PM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 7,249
Thanks: 63
Thanked 1,681 Times in 1,636 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: SelLength not working

Quote:
Originally Posted by smig View Post
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.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 12-09-2019, 02:04 PM   #5
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: SelLength not working

Quote:
Originally Posted by theDBguy View Post
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
smig is offline   Reply With Quote
Old 12-09-2019, 02:10 PM   #6
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 7,249
Thanks: 63
Thanked 1,681 Times in 1,636 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: SelLength not working

Quote:
Originally Posted by smig View Post
It means it select all text
it work OK if the Text box is on the main form, but not on a sub form
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?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 12-09-2019, 11:19 PM   #7
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: SelLength not working

Quote:
Originally Posted by theDBguy View Post
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
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

smig is offline   Reply With Quote
Old 12-10-2019, 03:29 AM   #8
moke123
AWF VIP
 
moke123's Avatar
 
Join Date: Jan 2013
Location: Massachusetts
Posts: 923
Thanks: 11
Thanked 272 Times in 256 Posts
moke123 will become famous soon enough
Re: SelLength not working

Quote:
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 by moke123; 12-10-2019 at 03:56 AM.
moke123 is offline   Reply With Quote
Old 12-10-2019, 03:58 AM   #9
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 6,323
Thanks: 11
Thanked 725 Times in 674 Posts
missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light
Re: SelLength not working

Quote:
Originally Posted by smig View Post
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)>
__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
Old 12-10-2019, 04:43 AM   #10
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: SelLength not working

Quote:
Originally Posted by moke123 View Post
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 is offline   Reply With Quote
Old 12-10-2019, 07:55 AM   #11
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 7,249
Thanks: 63
Thanked 1,681 Times in 1,636 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: SelLength not working

Quote:
Originally Posted by smig View Post
I'm trying to select only part of the text (A text I'm searching for)
Hi. Are you not able to post a demo copy of your db?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 12-10-2019, 09:12 AM   #12
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: SelLength not working

Quote:
Originally Posted by missinglinq View Post
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 is offline   Reply With Quote
Old 12-10-2019, 09:23 AM   #13
smig
Newly Registered User
 
Join Date: Nov 2009
Location: Israel
Posts: 2,086
Thanks: 89
Thanked 134 Times in 125 Posts
smig is on a distinguished road
Re: SelLength not working

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)
        Me.Materials_SubForm.Form.SetFocus
        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
even an Exit Sub just after this won't help

smig is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SelLength in DblClick event not working Skupfer Modules & VBA 5 06-18-2007 01:15 AM
[SOLVED] PLease help, problems with selstart & sellength not working as expected wim_007 Modules & VBA 3 10-11-2005 08:55 AM
Setting SelLength = 0 not working? KeithWilliams Forms 17 04-16-2004 12:25 AM
sellength to end ingrid Modules & VBA 5 08-27-2003 12:05 AM
Please Help If U Can In SelLength,,, Haitham Modules & VBA 1 11-30-2002 09:22 PM




All times are GMT -8. The time now is 07:26 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World