L
LDMueller
I have a form which runs the following code On Open:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
Me.cmdAddRecord.SetFocus
End Sub
It puts the focus on the Add Record command button and once I click this
button, it runs the following code:
Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.SetupDate = Now
NwMtrNum.SetFocus 'Move to the NwMtrNum field.
MsgBox "New matter numbers are incremented by 10's. Note the last
matter number used and increment the number by 10."
Exit_cmdAddRecord_Click:
Exit Sub
Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click
End Sub
All this works fine.
My problem is I want to combine it all on the On Open Event Procedure. When
I code it like the following, it acts like it's forgetting about "going to
Previous" lines and all I see is one line to enter new data. I've even tried
putting a delay code before "Me.AllowAdditions = True" and this didn't help.
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.SetupDate = Now
NwMtrNum.SetFocus 'Move to the NwMtrNum field.
MsgBox "New matter numbers are incremented by 10's. Note the last
matter number used and increment the number by 10."
End Sub
Can anyone help me with this?
Thank you in advance!
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
Me.cmdAddRecord.SetFocus
End Sub
It puts the focus on the Add Record command button and once I click this
button, it runs the following code:
Private Sub cmdAddRecord_Click()
On Error GoTo Err_cmdAddRecord_Click
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.SetupDate = Now
NwMtrNum.SetFocus 'Move to the NwMtrNum field.
MsgBox "New matter numbers are incremented by 10's. Note the last
matter number used and increment the number by 10."
Exit_cmdAddRecord_Click:
Exit Sub
Err_cmdAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmdAddRecord_Click
End Sub
All this works fine.
My problem is I want to combine it all on the On Open Event Procedure. When
I code it like the following, it acts like it's forgetting about "going to
Previous" lines and all I see is one line to enter new data. I've even tried
putting a delay code before "Me.AllowAdditions = True" and this didn't help.
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToRecord , , acPrevious
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.SetupDate = Now
NwMtrNum.SetFocus 'Move to the NwMtrNum field.
MsgBox "New matter numbers are incremented by 10's. Note the last
matter number used and increment the number by 10."
End Sub
Can anyone help me with this?
Thank you in advance!