Solved GoToControl error

Kayleigh

Member
Local time
Today, 18:24
Joined
Sep 24, 2020
Messages
709
Whilst automating parts of a data entry form, I have written code for a command button to enter today's date and then move onto the next field but a run-time error always occurs. Can you help?
This is the code:
Private Sub cmdToday_Click()
Me.fldDate = Date
DoCmd.GoToControl (Me.fldSession)
End Sub
 
Instead of DoCmd.GoToControl, try Me.fldSession.SetFocus as a way to activate another control. It should, however, be the last thing before you leave the current routine. I.e. just as the DoCmd was the last instruction of your _Click routine, the .SetFocus should be the last instruction in its place.
 
Whilst automating parts of a data entry form, I have written code for a command button to enter today's date and then move onto the next field but a run-time error always occurs. Can you help?
This is the code:
Private Sub cmdToday_Click()
Me.fldDate = Date
DoCmd.GoToControl (Me.fldSession)
End Sub
What was the error message? Just curious...

Have you tried it this way?
Code:
DoCmd.GoToControl "fldSession"
 
error message with vba.png
 

Users who are viewing this thread

Back
Top Bottom