Form Load New Record not working

jenfish7871

New member
Local time
Today, 09:12
Joined
Jul 16, 2012
Messages
7
I am using Access 2010. I have setup a Navigation form (Navigation) and several subforms. On one form, Create New FP Sample, I have entered the following code to have it load a new record.

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

However, when I open the database, this form does not load a new record immediately. It will eventually load a new record after selecting a different subform several times.

I have another subform, Create New Ing Sample, with this same code and it loads a new record when opened just fine.

What am I missing? Is there a reason the one form would load the new record and the other would not?

Any help is greatly appreciated!
 
Try this code:
Code:
DoCmd.RunCommand acCmdRecordsGoToNew
Do you have any other code that might be interrupting this code?
 
I will try that code and see what happens.

I am new to VB. The only other code I have worked on is for a different form, frmFoodReports and looks like this:

Private Sub btnResetFP_Click()
Me.cboFPNum = Null
Me.txtFPLot = Null
Me.cboFPFormula = Null
Me.txtProdBegDate = Null
Me.txtProdEndDate = Null
Me.txtFPBegTestDate = Null
Me.txtFPEndTestDate = Null
Me.cboFPType = Null
Me.txtFPLine = Null
Me.sfrmFPResultsAll.Form.Requery
End Sub
Private Sub btnSearchFPQry_Click()
Me.sfrmFPResultsAll.Requery
Me.sfrmFPResultsAll.Form.Requery
If Me.sfrmFPResultsAll.Form.Recordset.RecordCount = 0 Then
MsgBox "No Records Available"
End If
End Sub
Private Sub btnSearchQry_Click()
Me.sfrmIngredientResultsAll.Requery
Me.sfrmIngredientResultsAll.Form.Requery
If Me.sfrmIngredientResultsAll.Form.Recordset.RecordCount = 0 Then
MsgBox "No Records Available"
End If
End Sub
Private Sub btnReset_Click()
Me.cboIngNum = Null
Me.txtIngLot = Null
Me.txtIngBegTestDate = Null
Me.txtIngEndTestDate = Null
Me.sfrmIngredientResultsAll.Form.Requery
End Sub

And I am having trouble with that form loading with the Navigation also. I get Parameter Value errors for every control on this form whenever I click it on the navigation form.
 
I tried the code you posted and it seems to work. I have opened and closed my database several times and the form loads a new record each time I click it.

Also, I'm not getting the Parameter Value errors for the controls on my frmFoodReports form any longer. Could that code have been causing the issue with my other form? I hate not knowing the cause of an issue so I can avoid it in the future.

Thank you for your help!
 
I don't know what parameter was popping up and why. But if it does, let us know. And remember to always Debug > Compile when you write code.
 
Still having a few issues. I should include that my database is split with tables in a back end file on a shared network drive and a front end on each PC (there are 3) that access the data in the tables through multiple forms and queries.

The code I tried yesterday is working and my form Create New FP Sample loads a new record; however, I have a field called Test Date on this form that default is Date() to populate the current date and it is not populating. On the similar form, Create New Ing Sample, the Test Date populates fine. I have not changed the VB code on Create New Ing Sample to the above code because it worked fine to begin with.

Any other thoughts? Thanks in advance!!
 
Put the Default Value directly in the property sheet of the control.
 
Of course! Thanks for reminding me of that option! Worked like a charm.:)
 

Users who are viewing this thread

Back
Top Bottom