Rocky Smolin
rockysmolin at bchacc.com
Fri Apr 3 09:26:16 CDT 2009
Max: That looks like a very 'robust' solution. I ended up using Charlotte's snip for the click event and Application.SetOptions to set the enter behavior to select the whole field. But that Application.SetOptions does not carry from one form to another. You have to issue it in each form where you want that behavior. Setting it through the menus worked but only until you exited. Rocky -----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