Starting point when enter a field

  • Thread starter Thread starter Snurre
  • Start date Start date
S

Snurre

Hi,

How can I do this for all controls on a form, or do I have
make a Sub Field_click for every field on the form..

Private Sub Field_click()
Me!Field.SelStart = 0
End Sub

snurre
 
So you want to be able to click *anywhere* in the control, but have the
focus automatically move to the beginning of the control???

I think I would found that interface annoying - not being able to click
where-ever I wished. In any case, you could try setting the SelStart and
SelLength in the GotFocus event of every control if you wanted to.

If you want something that cycles through all the text boxes and combos on
your form, and sets the OnGotFocus property to a generic function that does
the work, you could try something along these lines:
Dim ctl As Control
Dim strName As String

DoCmd.OpenForm "MyForm", acDesign
For Each ctl In Forms(strForm).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
strName = ctl.Name
ctl.OnGotFocus = "=MyFunction([" & strName & "])"
End Select
Next
Set ctl = Nothing
 
Back
Top