Re: Select all when control gets focus
- From: strive4peace <strive4peace2006@xxxxxxxxx>
- Date: Thu, 01 Feb 2007 03:03:28 -0500
FindRecord_N, choosing Light Colors
---
Hi Bill,
"Nice piece of work on the General code to be called from any unbound control for ID lookup."
Thanks, Bill. I can't help myself ... this is one better -- it can be put into a general module -- but you have to specify more to use it (at the least, just one parameter -- not FULLY tested)...
'used by Find combos on forms
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FindRecord_N
' find record given a numeric fieldname and
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)
'set up Error Handler
On Error GoTo Proc_Err
Dim f As Form
If IsMissing(pF) Then
Set f = Screen.ActiveForm
Else
Set f = pF
End If
If pRecordID = 0 Then
'if nothing is picked in the active control, exit
If IsNull(f.ActiveControl) Then Exit Function
'set value to look up by what is selected
pRecordID = f.ActiveControl
'clear the choice to find
f.ActiveControl = Null
End If
'save current record if changes were made
If f.Dirty Then f.Dirty = False
'find the first value that matches
f.RecordsetClone.FindFirst pKeyFieldname _
& "= " _
& pRecordID
'if a matching record was found, then move to it
If Not f.RecordsetClone.NoMatch Then
f.Bookmark = f.RecordsetClone.Bookmark
End If
Proc_Exit:
On Error Resume Next
Set f = Nothing
'close and release object variables
Exit Function
Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number & " ProcedureName"
'press F8 to step through code and debug
'remove next line after debugged
Stop: Resume
Resume Proc_Exit
End Function
'~~~~~~~~~~~~
> 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:
from the design view of the form:
set BackColor to the highlight color
then, set the BackColor to be Transparent
set the ForeColor to something that will show up with either BackColor
when the user tabs into the control, the BackColor set before the 'Transparent' command will take effect -- maybe something like white or light yellow?
*** choosing Light Colors ***
Even though you do not have light (faded) colors to pick from on the color list, here is what I do:
1. pick a fill color from the icon drop-down
2. then click on the builder button (...) for the Color Property (ie: BackColor, ForeColor, Bordercolor -- Format tab of the property ***)
3. click on the "Define Custom Colors >>" button
4. drag the triangle up the slider for a lighter shade
***
"...text Phone field..."
aha! I assume you are using an InputMask?
I have had troubles with this exact type of data ...
How I resolved it was to restructure the data for Phone because it was a difficult solution to implement -- it can be done -- and one way is to use another control -- another is to keep looking up what is found on the Change event (very intense). The simplest solution, to me, was to store duplicate numbers and recognize that "after the fact" -- not the most efficient -- but it depends on your terms :)
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
BFish via AccessMonster.com wrote:
Thank you for your reply Crystal,.
You are correct for my band aid fix. It is better to set the control to null
rather than a ZLS.
Nice piece of work on the General code to be called from any unbound control
for ID lookup.
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?
Here is the main reason why I'm trying to accomplish this endeavor. The
formatted and unbound combobox is an ID lookup on a text Phone field. Data
is stored as digit characters only, i.e. without the parentheses, hyphen or
spaces. This so that the users can enter the relevant data quickly and have
a bit more structured data, but mostly for the speed and is formatted so they
can easily see what they have entered. I have code for on the change event
that replaces the rowsource to match as if the auto expand property is
functioning.
To give the users piece of mind after a successful lookup or a "not in the
list" I would like to retain the typed information from the combobox so they
can verify (even after the message box for "not in the list" comes up with
their data) that that was what they typed. Also for the next lookup entry
(this form stays open until all customer invoices for the prior day have been
entered) a F2 type highlight of the combobox as soon as it has focus would be
ideal to get around the phone mask, particularly when clicked into and would
solve both issues.
An easy answer would be to teach (and I have tried) the users just to use the
F2 key but unfortunately I have one old dog that will not learn new tricks.
Hopefully the above information is discernable,
Thanks again and Woof Woof,
Bill
strive4peace wrote:Hi Bill,
it just seems to me that you should do
me.combo_controlname = Null
as soon as whatever should happen with the information is successful.
- 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
- Prev by Date: Re: Select all when control gets focus
- Next by Date: Rest Toggle Control
- Previous by thread: Re: Select all when control gets focus
- Next by thread: Re: Select all when control gets focus
- Index(es):