Starting point when enter a field

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
 
S

snurre

I have tried, but this works only when TAb into field, not
when clicking in field...
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top