Goto new record in form automatically

JohnGo

Registered User.
Local time
Today, 05:55
Joined
Nov 14, 2004
Messages
70
When I open my orderform I would like to have a new record to be shown instead of the oldest one. Each time adding an order for a customer I have to touch the new button first. I would like to autofocus on a new record automatically.

I thought about adding code to the 'on open event' of the form, I did the following:
DoCmd.GoToRecord , "", acLast

but it doesn't help.

Does anybody know how to achieve it?
(by the way I know about setting data-entry to yes in the form properties but that setting prevents me from browsing through old records)
 
Try this


Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
 
Hi there, it didn't work. It's a subform and I've put the code in the subforms on load event, but it doesn't help. The form still begins with the oldest record instead of a new record
 
try creating a macro,
'open form' and set datamode to 'Add'
hope this is what your looking for?
 
i use this code, for eatch field i want to have in new record




Code:
DoCmd.GoToRecord , , acNewRec
If Me.NewRecord And Me.CurrentRecord > 1 Then
Me.trib_jug = DLast("[trib_jug]", "tbl1")
end if
 
The code that I submitted does not go in subform but the main form.
 
I've struggled with this particular problem for a little while and I think I have cracked it as follows

In the OnLoad or OnOpen procedure in the subform

DoCmd.GoToRecord , , acNewRec


In the main form

in the OnCurrent procedure for the main form

Me![subFormName].SetFocus

Me![subFormName].Form![Control].SetFocus


( note the subFormName is as defined in the properties panel for the subform as it is embedded into the main form NOT as is listed in either the database manager or the associated list in VBA)


and in the OnEnter procedure in the embedded subform

DoCmd.GoToRecord , , acNewRec

Hope this helps
 

Users who are viewing this thread

Back
Top Bottom