Rocky Smolin
rockysmolin at bchacc.com
Fri Apr 3 10:38:28 CDT 2009
It would select the entire field, but in this case the field is only length
= 1 so it works well for that.
Rocky
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Friday, April 03, 2009 8:23 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Selecting Entire Field
What happens when you try to click a particular point in the text to edit
it?
Charlotte Foust
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Friday, April 03, 2009 2:38 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Selecting Entire Field
Rocky,
Dont know if you solved this last night but if not the code below will
select the entire field whether tabbed in or clicked in, regardless of hte
global setting in Tools/Options.
Max
ps. Haven't got access to previous correspondece/postings so the title may
be out of sync. Sorry.
' Test the ability to select the entire contents of a bound field regardless
of the setting in Tools/Options/Keyboard ' tests only a
Currencyfield,Datefield,Numberfield,Stringfield
' does not work for boolean fields
' for each field we need to call the sub for both the OnClick event AND the
GotFocus event ' Max Sherman Apr 2009 Option Compare Database Option
Explicit Private ActiveCtl As Control
Private Sub BooleanField_Click()
' do not call sSelLength for boolean
End Sub
Private Sub BooleanField_GotFocus()
' do not call sSelLength for boolean
End Sub
Private Sub CurrencyField_Click()
Call sSelLength
End Sub
Private Sub CurrencyField_GotFocus()
Call sSelLength
End Sub
Private Sub DateField_Click()
Call sSelLength
End Sub
Private Sub DateField_GotFocus()
Call sSelLength
End Sub
Private Sub NumberField_Click()
Call sSelLength
End Sub
Private Sub NumberField_GotFocus()
Call sSelLength
End Sub
Private Sub StringField_Click()
Call sSelLength
End Sub
Private Sub StringField_GotFocus()
Call sSelLength
End Sub
Private Sub sSelLength()
On Error GoTo errhandler
Set ActiveCtl = Application.Screen.ActiveControl
Debug.Print Application.Screen.ActiveControl.Name
With ActiveCtl
.SetFocus
.SelStart = 0
.SelLength = Len(Nz(ActiveCtl, "")) + 1
End With
exithere:
Exit Sub
errhandler:
Select Case Err.Number
Case 2474 ' not active control
Debug.Print Application.Screen.ActiveControl.Name
MsgBox Application.Screen.ActiveControl.Name
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
End Select
Resume exithere
End Sub
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com