Form not setting acrecnew (1 Viewer)

swell

Member
Local time
Today, 05:17
Joined
Mar 10, 2020
Messages
77
Hi,
The following code works (waiting for a new record entry) when I enter it into the code window then change the form from design view to form view.
But if I close the form and then re-open, it fails and just shows the last entry (or record).

The form has a sub form showing the contents of the table.
The code sets focus to the sub form in an on Load event and selects the last record.
The main form also shows the last record in the dataset.
What is required is that the main form be ready for the entry of a new record.
I have trolled the net to find a solution.


Code:
Private Sub Form_Open(Cancel As Integer)

'DoCmd.GoToRecord acDataForm, "Member Activity Entry", acNewRec
   Me.SetFocus
   DoCmd.GoToRecord , , acNewRec
' I tried same result
'  DoCmd.GoToRecord acForm, Me.name, acNewRec
'
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:17
Joined
May 7, 2009
Messages
19,233
move your code to the Form's Load event
 

isladogs

MVP / VIP
Local time
Today, 05:17
Joined
Jan 14, 2017
Messages
18,216
I have trolled the net to find a solution.

Sorry to go off topic but your misspelling of 'trawling' the net did make me laugh.😀
Oh and I agree with arnelgp on how to fix your issue
 

swell

Member
Local time
Today, 05:17
Joined
Mar 10, 2020
Messages
77
:giggle:



isladogs
Sorry to go off topic but your misspelling of 'trawling' the net did make me laugh.😀
Oh and I agree with arnelgp on how to fix your issue
Felt as dumb as a Troll else I would have just trawled ;)

arnelgp
move your code to the Form's Load event
I had originally had it in there, I just reinserted into the onload event.
Now it doesn't go to acNewRec when I close the VBA code window just shows the first record.
Also closing and opening the form gives same result.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:17
Joined
May 7, 2009
Messages
19,233
did you put it on the Main Form's Load event?
 

Dreamweaver

Well-known member
Local time
Today, 05:17
Joined
Nov 28, 2005
Messages
2,466
Can't you set the forms data entry to yes that way a new record is displayed
 

Users who are viewing this thread

Top Bottom