Re: Select all when control gets focus



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 when
entering the control by clicking, tabbing or enter key is not possible?

no, not true:

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

--
Message posted via http://www.accessmonster.com

.



Relevant Pages