If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Tab box opens with all selected
On my forms when I move from tab to tab all the text is selected in the newly
opened text box. Is there some way to have them open with out having everything selected? Thanks |
#2
|
|||
|
|||
Tab box opens with all selected
TES,
Well, actually, you're "moving from control to control, using the Tab key"... which is the correct way to navigate a form. Try this in each text control's OnEnter and /or Click event. I'll use a control named [LastName] For Tabbing into a control... Private Sub LastName_Enter() LastName.SelLength = 0 End Sub For Mouse Clicking into a control... Private Sub LastName_Click() LastName.SelStart = 0 End Sub -- hth Al Campagna Microsoft Access MVP 2007-2009 http://home.comcast.net/~cccsolutions/index.html "Find a job that you love... and you'll never work a day in your life." "TES" wrote in message ... On my forms when I move from tab to tab all the text is selected in the newly opened text box. Is there some way to have them open with out having everything selected? Thanks |
#3
|
|||
|
|||
Tab box opens with all selected
Add the following function to the form's module:
Private Function Unselect() Dim ctrl As Control Set ctrl = Me.ActiveControl ctrl.SelStart = 0 ctrl.SelLength = 0 End Function If you'd prefer the insertion point to be at the end of the control's contents rather than at the start, change the 'ctrl.SelStart = 0' line to: ctrl.SelStart = Len(Nz(ctrl, "")) Then in the properties sheet for each text box whose contents you want to be 'unselected' when it receives focus enter the following as the On Got Focus event property: =Unselect() Ken Sheridan Stafford, England TES wrote: On my forms when I move from tab to tab all the text is selected in the newly opened text box. Is there some way to have them open with out having everything selected? Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/201002/1 |
#4
|
|||
|
|||
Tab box opens with all selected
"TES" wrote in message
... On my forms when I move from tab to tab all the text is selected in the newly opened text box. Is there some way to have them open with out having everything selected? If you want to change the default behavior for all fields on all forms, you can change the option setting "Behavior Entering Field", on the Keyboard tab of the Access Options dialog, from "Select entire field" to "Go to start of field" or "Go to end of field". -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) |
#5
|
|||
|
|||
Tab box opens with all selected
Ken,
When I looked up my old code for this question, in my test database, I had... LastName.SelStart = Len(LastName) LastName.SelLength = 0 But, I remmed out the SelStart portion, and it didn't seem to make any difference when tabbing into the field. The behavior was the same either with my =Len(LastName) or your =0. And, I now question the reason for determining the SelLength... particularly as regards ultimately setting the SelLength = 0. Have you found some advantage to using the SelStart? Al Campagna "KenSheridan via AccessMonster.com" u51882@uwe wrote in message news:a36f9422354c1@uwe... Add the following function to the form's module: Private Function Unselect() Dim ctrl As Control Set ctrl = Me.ActiveControl ctrl.SelStart = 0 ctrl.SelLength = 0 End Function If you'd prefer the insertion point to be at the end of the control's contents rather than at the start, change the 'ctrl.SelStart = 0' line to: ctrl.SelStart = Len(Nz(ctrl, "")) Then in the properties sheet for each text box whose contents you want to be 'unselected' when it receives focus enter the following as the On Got Focus event property: =Unselect() Ken Sheridan Stafford, England TES wrote: On my forms when I move from tab to tab all the text is selected in the newly opened text box. Is there some way to have them open with out having everything selected? Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/201002/1 |
#6
|
|||
|
|||
Tab box opens with all selected
Al:
Assigning a zero to the SelStart property won't make any difference if you want the insertion point at the start of the value in the control, so could be omitted. Where it really comes into play is when positioning it at the end of the value, which I've found over the years is often requested in posts here and elsewhere. In the latter case calling the Nz function to return a zero-length string is also necessary, however, to cater for a Null in the control, e.g. when at a new record, as Len(Null) is Null and the SelStart property can't be Null. If positioning the insertion point at the end of the value assigning a zero to the SelLength property becomes redundant of course, as there is nothing beyond that to select. Ken Sheridan Stafford, England Al Campagna wrote: Ken, When I looked up my old code for this question, in my test database, I had... LastName.SelStart = Len(LastName) LastName.SelLength = 0 But, I remmed out the SelStart portion, and it didn't seem to make any difference when tabbing into the field. The behavior was the same either with my =Len(LastName) or your =0. And, I now question the reason for determining the SelLength... particularly as regards ultimately setting the SelLength = 0. Have you found some advantage to using the SelStart? Al Campagna Add the following function to the form's module: [quoted text clipped - 32 lines] Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/201002/1 |
#7
|
|||
|
|||
Tab box opens with all selected
Ken,
Agreed. Probably that's why I had the LastName.SelLength = Len(LastName) in the first place. I may have done that for an old "start at end of string" question. And... good point on the NZ on the Len. I hadn't considered Nulls. Thanks, Al "KenSheridan via AccessMonster.com" u51882@uwe wrote in message news:a370f118f37d3@uwe... Al: Assigning a zero to the SelStart property won't make any difference if you want the insertion point at the start of the value in the control, so could be omitted. Where it really comes into play is when positioning it at the end of the value, which I've found over the years is often requested in posts here and elsewhere. In the latter case calling the Nz function to return a zero-length string is also necessary, however, to cater for a Null in the control, e.g. when at a new record, as Len(Null) is Null and the SelStart property can't be Null. If positioning the insertion point at the end of the value assigning a zero to the SelLength property becomes redundant of course, as there is nothing beyond that to select. Ken Sheridan Stafford, England Al Campagna wrote: Ken, When I looked up my old code for this question, in my test database, I had... LastName.SelStart = Len(LastName) LastName.SelLength = 0 But, I remmed out the SelStart portion, and it didn't seem to make any difference when tabbing into the field. The behavior was the same either with my =Len(LastName) or your =0. And, I now question the reason for determining the SelLength... particularly as regards ultimately setting the SelLength = 0. Have you found some advantage to using the SelStart? Al Campagna Add the following function to the form's module: [quoted text clipped - 32 lines] Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/201002/1 |
#8
|
|||
|
|||
Tab box opens with all selected
Of Course you could avoid the call to LEN entirely by using
LastName.SelStart = 32000 That works as longs as the length is less than 32000 characters John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County Al Campagna wrote: Ken, Agreed. Probably that's why I had the LastName.SelLength = Len(LastName) in the first place. I may have done that for an old "start at end of string" question. And... good point on the NZ on the Len. I hadn't considered Nulls. Thanks, Al "KenSheridan via AccessMonster.com" u51882@uwe wrote in message news:a370f118f37d3@uwe... Al: Assigning a zero to the SelStart property won't make any difference if you want the insertion point at the start of the value in the control, so could be omitted. Where it really comes into play is when positioning it at the end of the value, which I've found over the years is often requested in posts here and elsewhere. In the latter case calling the Nz function to return a zero-length string is also necessary, however, to cater for a Null in the control, e.g. when at a new record, as Len(Null) is Null and the SelStart property can't be Null. If positioning the insertion point at the end of the value assigning a zero to the SelLength property becomes redundant of course, as there is nothing beyond that to select. Ken Sheridan Stafford, England Al Campagna wrote: Ken, When I looked up my old code for this question, in my test database, I had... LastName.SelStart = Len(LastName) LastName.SelLength = 0 But, I remmed out the SelStart portion, and it didn't seem to make any difference when tabbing into the field. The behavior was the same either with my =Len(LastName) or your =0. And, I now question the reason for determining the SelLength... particularly as regards ultimately setting the SelLength = 0. Have you found some advantage to using the SelStart? Al Campagna Add the following function to the form's module: [quoted text clipped - 32 lines] Thanks -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/201002/1 |
Thread Tools | |
Display Modes | |
|
|