Jul 06 2021 10:05 PM
Jul 06 2021 10:05 PM
Many years ago, I acquired some code to allow me to have the cursor start on my first line of my forms. Even though I have changed the lines to correspond with each form, for some reason, I can no longer get it to work.
The code is,
“Private Sub Form_Current()
If DateofPurchase.NewRecord = True Then
Previously, this has worked fine. But I can no longer get it to work. I also clicked Debug, Compile. Still it doesn’t work.
What I want is for the cursor to appear on the first line of the form instead of where it was left on the previous entry entered by end user.
Jul 07 2021 01:29 PM
I see that nobody has responded, possibly because, like me, other forum members aren't quite clear what you are asking.
1. Please clarify what type of form you are using: single/continuous/datasheet/split
2. When you refer to the first line of your forms, do you mean the first record or the first control?
3. Why do you need to set the focus to DateOfPurchase using code?
Have you tried altering the tab order so that control is the first item in the tab order?
Jul 07 2021 01:34 PM
Forgot to say...
The NewRecord property is for the form...not a specific control.
Something like this should work
Sub NewRecordMark(frm As Form) If frm.NewRecord = True Then MsgBox "You're in a new record." End Sub
Jul 08 2021 01:15 PM
Thank you for responding so quickly.
What I am trying to do is get the cursor to appear on the first control of the record when the end user is finished entering data on the previous record. What the cursor is doing at present is remaining on the last control entered by the end user when a new record is begun, although on the new record.
I was given this code many years ago and it always worked. But now it is not. I am trying to figure out what is wrong. I do not write code yet. Will be learning soon.
Private Sub Form_Current()
If Me.NewRecord = True Then
Jul 08 2021 01:21 PM
Jul 08 2021 08:59 PM
Jul 08 2021 09:43 PM
Jul 08 2021 09:46 PM
Jul 15 2021 01:44 PM
Jul 15 2021 04:58 PM
Jul 15 2021 05:31 PM