W
winsa
Hi
Working with Access2003. Getting a Reserved Error when I try to click a
button that I've programmed to add a new record.
This is the code behind the button (it is on a subform):
Private Sub cmd_NavBarAddRecord_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "testfrm_EDIT_MVDETAILS"
DoCmd.OpenForm stDocName
Forms!testfrm_EDIT_MVDETAILS.Filter = ""
DoCmd.GoToRecord , , acNewRec
Forms!testfrm_EDIT_MVDETAILS!MVPOLICY_IDX = Forms!testfrm_MV!MVPOLICY_IDX
Forms!testfrm_EDIT_MVDETAILS!MV_LINE = DCount("MVDET_IDX", "tbl_MVDETAILS",
"[MVPOLICY_IDX]= '" & Me!MVPOLICY_IDX & "'") + 1
Exit_cmd_NavBarAddRecord_Click:
Exit Sub
Err_cmd_NavBarAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmd_NavBarAddRecord_Click
End Sub
It brings up a pop-up form where the user can enter in all the relevant
information. I have a Save&Exit button with the following code:
Private Sub cmd_CLOSEFRM_Click()
On Error GoTo Err_cmd_CLOSEFRM_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
Forms!testfrm_MV.SetFocus
Forms!testfrm_MV!TOTALPRM.Requery
Exit_cmd_CLOSEFRM_Click:
Exit Sub
Err_cmd_CLOSEFRM_Click:
MsgBox Err.Description
Resume Exit_cmd_CLOSEFRM_Click
End Sub
After I fill in some fields and click on the above button, I get a dialog
box with "Reserved Error" - no number, no other message. I click okay and it
just takes me back to my pop-up form. When I click on cmd_CLOSEFRM again,
everything works fine - the record is saved and it is then displayed
correctly in my subform.
Can someone explain what's going on here, and/or if I've got an error in my
code somewhere?
Thanks in anticipation.
Working with Access2003. Getting a Reserved Error when I try to click a
button that I've programmed to add a new record.
This is the code behind the button (it is on a subform):
Private Sub cmd_NavBarAddRecord_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "testfrm_EDIT_MVDETAILS"
DoCmd.OpenForm stDocName
Forms!testfrm_EDIT_MVDETAILS.Filter = ""
DoCmd.GoToRecord , , acNewRec
Forms!testfrm_EDIT_MVDETAILS!MVPOLICY_IDX = Forms!testfrm_MV!MVPOLICY_IDX
Forms!testfrm_EDIT_MVDETAILS!MV_LINE = DCount("MVDET_IDX", "tbl_MVDETAILS",
"[MVPOLICY_IDX]= '" & Me!MVPOLICY_IDX & "'") + 1
Exit_cmd_NavBarAddRecord_Click:
Exit Sub
Err_cmd_NavBarAddRecord_Click:
MsgBox Err.Description
Resume Exit_cmd_NavBarAddRecord_Click
End Sub
It brings up a pop-up form where the user can enter in all the relevant
information. I have a Save&Exit button with the following code:
Private Sub cmd_CLOSEFRM_Click()
On Error GoTo Err_cmd_CLOSEFRM_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
Forms!testfrm_MV.SetFocus
Forms!testfrm_MV!TOTALPRM.Requery
Exit_cmd_CLOSEFRM_Click:
Exit Sub
Err_cmd_CLOSEFRM_Click:
MsgBox Err.Description
Resume Exit_cmd_CLOSEFRM_Click
End Sub
After I fill in some fields and click on the above button, I get a dialog
box with "Reserved Error" - no number, no other message. I click okay and it
just takes me back to my pop-up form. When I click on cmd_CLOSEFRM again,
everything works fine - the record is saved and it is then displayed
correctly in my subform.
Can someone explain what's going on here, and/or if I've got an error in my
code somewhere?
Thanks in anticipation.