Not working, why?

A

albycindy

I'm doing exactly what the For Dummies book says and it's still not working.
I want a date/time box on my form to have the focus when the form is opened
so have written this....

Private Sub Form_Load()
Expected Collection Date.SetFocus
End Sub


How hard can it be???
 
D

Douglas J Steele

It's the spaces. Most of us recommend strongly that you not have spaces in
your control or field names.

If you must have the spaces, enclose the control or field name in square
brackets. Assuming that Expected Collection Date is a control on your
current form, try

Private Sub Form_Load()
Me![Expected Collection Date].SetFocus
End Sub

Of course, you could also set the form's Tab Order so that Expected
Collection Date is the first control, and then you wouldn't require this
code.
 
D

Dennis

You can have spaces but you must put square brackets around to tell it that
it is all one field

[Expected Collection Date].SetFocus
 
Top