Re: Select all when control gets focus
- From: strive4peace <strive4peace2006@xxxxxxxxx>
- Date: Thu, 01 Feb 2007 23:44:37 -0500
Select Whole Control on click
---
Hi Bill,
"Your module code is even more outstanding."
thank you
> Thanks again and if you have any insight on a "F2 Key" type code please let me know.
Short of
SendKeys "{F2}"
.... for selecting the whole phone number when you click in ... how about something like this:
'~~~~~~~~~~~~~~
Private Sub Phone_Click()
Me.Phone.SelStart = 1
Me.Phone.SelLength = 14
End Sub
'~~~~~~~~~~~~~~~
since you are not storing the symbols, I hard-coded numbers in -- since the length in the control is > len(fieldname) ... you will need to test what is there and make appropriate adjustments...
this is annoying in that each time they click, it will keep selecting everything (so they won't be able to click a digit and change it -- testing to see if they have left the field since their last click (global variable) might be a good idea - set on GotFocus, clear on LostFocus
another alternative is to make a command button for them to click on
caption --> Select Phone
click [Event Procedure] --> me.phone.setfocus
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
BFish via AccessMonster.com wrote:
Hi again Crystal,.
Function FindRecord_N( _
pKeyFieldname As String _
, Optional pRecordID = 0 _
, Optional pF _
)
'PARAMETERS
'pKeyFieldname = name of numeric key field
'pRecordID = numeric value of key field to look up
'pF --> form reference (if missing, uses active form)
Your module code is even more outstanding. Obviously if the form is based a
query with multiple ID fields (one business ID but also many phone ID for
that same business) your code will allow one combo lookup on a business name
and another for phone by just passing the parameters in after update event in
the applicable combo.
I'm all about simple and clean!
So with your reply I gather trying to highlight the control data whenno, not true:
entering the control by clicking, tabbing or enter key is not possible?
command will take effect -- maybe something like white or light yellow?
*** choosing Light Colors ***
I'm afraid I did correctly pose my question. Is there any way via code to on
a controls focus to select all the data in that control so that when the user
types new data all the old data is overwritten? Much like using the F2 key
after the control has focus and new data is then entered.
"...text Phone field..."
aha! I assume you are using an InputMask?
You are correct I did fail to mention of the Input Mask. And yes I have used
the "on change" event to update as typed with this code:
********************
Private Sub Combo30_Change()
Combo30.RowSource = "SELECT Format([Phone],'(@@@) @@@-@@@@') " & _
"AS NewPhone FROM tblPhone WHERE " & _
"(((Format([Phone],'(@@@) @@@-@@@@')) Like " & _
"[Forms]![frmInvoiceEntry]![Combo30].[Text] & '*')) " & _
"ORDER BY tblPhone.Phone;"
Dim ctl As Access.Control
Dim blnMyFieldHasFocus As Boolean
On Error Resume Next
Set ctl = Me.ActiveControl
If Not (ctl Is Nothing) Then
If ctl Is Me!Combo30 Then
blnMyFieldHasFocus = True
End If
End If
If blnMyFieldHasFocus Then
Me.Combo30.Dropdown
End If
End Sub
***** And on the Forms Current event ******
Private Sub Form_Current()
Combo30.RowSource = "SELECT Format([Phone],'(@@@) @@@-@@@@') AS NewPhone " &
_
"FROM tblPhone " & _
"ORDER BY Format([Phone],'(@@@) @@@-@@@@')
;"
End Sub
*********************
Thanks again and if you have any insight on a "F2 Key" type code please let
me know.
Bill
- Follow-Ups:
- Re: Select all when control gets focus
- From: BFish via AccessMonster.com
- Re: Select all when control gets focus
- References:
- Re: Select all when control gets focus
- From: BFish via AccessMonster.com
- Re: Select all when control gets focus
- From: strive4peace
- Re: Select all when control gets focus
- From: BFish via AccessMonster.com
- Re: Select all when control gets focus
- Prev by Date: Re: Forms
- Next by Date: Re: Not In List requery & error message on Cancel Add
- Previous by thread: Re: Select all when control gets focus
- Next by thread: Re: Select all when control gets focus
- Index(es):
Loading