MS Access ADD New Record Help!

I have a form called frmCallTypes with a subform called frmCallTypePrices on the main form i have a  cmd button called cmdAddRec  i want it to on click add on record for the main form and add 3 records for the subform  with values placed in each record that is added below works if i have a cmd button on the subform

Private Sub cmdAddRec_Click()
On Error GoTo Err_cmdAddRec_Click


    DoCmd.GoToRecord , , acNewRec
    Me.StartTime = "12:00:00 AM"
    Me.EndTime = "7:59:59 AM"
    DoCmd.GoToRecord , , acNewRec
    Me.StartTime = "8:00:00 AM"
    Me.EndTime = "4:59:59 PM"
    DoCmd.GoToRecord , , acNewRec
    Me.StartTime = "5:00:00 PM"
    Me.EndTime = "11:59:59 PM"

Exit_cmdAddRec_Click:
    Exit Sub

Err_cmdAddRec_Click:
    MsgBox Err.Description
    Resume Exit_cmdAddRec_Click
    
End Sub

Open in new window


but again i dont want a button on the subform i want it on the main form, and it needs to add on blank record for the main form and the listed above for the subform. thank you
Blueice13085Asked:
Who is Participating?
 
Blueice13085Author Commented:
ah well i figured it out and thanks for the help everyone!

Private Sub cmdNewRec_Click()
DoCmd.GoToRecord , , acNewRec
Me![CallTypePrice].Value = "0"
DoCmd.RunCommand acCmdSaveRecord
'sets the focus on the subform
Me![frmCallTypePrices].SetFocus
DoCmd.GoToRecord , , acNewRec
Me![frmCallTypePrices].Form![StartTime].Value = "12:00:00 AM"
Me![frmCallTypePrices].Form![EndTime].Value = "7:59:59 AM"
Me![frmCallTypePrices].SetFocus
DoCmd.GoToRecord , , acNewRec
Me![frmCallTypePrices].Form![StartTime].Value = "8:00:00 AM"
Me![frmCallTypePrices].Form![EndTime].Value = "4:59:59 PM"
Me![frmCallTypePrices].SetFocus
DoCmd.GoToRecord , , acNewRec
Me![frmCallTypePrices].Form![StartTime].Value = "5:00:00 PM"
Me![frmCallTypePrices].Form![EndTime].Value = "11:59:59 PM"

End Sub

Open in new window

0
 
Blueice13085Author Commented:
I answered my own queston
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.