K
Kathy R.
Using Access 2007
I have a form (frmNewFamily) that is opened when a NotInList event is
triggered from a subform in a different form
(frmAttendance/sfrAttendee). I have a "Save" button on the frmNewFamily
that will save the record, close the frmNewFamily and requery the combo
boxes on sfrAttendee.
I have it working just great, but I want to delete one of the combo
boxes. But as soon as I comment out the requery line, the Save button
stops functioning properly. It will save the record to the table, but
not close the form or requery the combo box. The same thing happens if
I switch the two requery lines without commenting it out.
sfrAttendee has two combo boxes - CombinedName_cbo (which I want to
remove) and LastName_cbo, along with the control AtIndID, all of which
use the AtIndId as the Control Source. The combo boxes have different
Row Sources.
I've posted the code for the save button below. Can someone tell me why
how to delete the row in my code and the combo box without it causing my
save button to stop working? And, hopefully explain to me why it is
exhibiting this behavior. I'm trying to learn from my mistakes, but
this one has me stumped. :-(
Kathy R.
Private Sub SaveRec_cmd_Click()
On Error GoTo SaveRec_cmd_err
If IsNull(Me!sfrNewIndividual.Form.IndID) Then
MsgBox "Please place your cursor in the ""First Name"" field" & Chr$(13) & _
"of the individual you wish to add to the attendance form." _
, vbOKOnly, "CHOOSE SOMEONE!"
GoTo exit_sub:
End If
'saves new record
DoCmd.RunCommand acCmdSaveRecord
'commenting out the CombinedName_cbo.Requery line or switching
'the CombinedName line with the LastName line causes
'the Save button to save the record, but not requery the subform.
Forms!frmAttendance!sfrAttendee.Form.CombinedName_cbo.Requery
Forms!frmAttendance!sfrAttendee.Form.LastName_cbo.Requery
Forms!frmAttendance!MemberList_lst.Requery
'fills in the new info on sfrAttendee
Forms!frmAttendance!sfrAttendee.Form.AtIndID =
Forms!frmNewFamily.sfrNewIndividual.Form.IndID
'closes frmNewFamily
DoCmd.Close
SaveRec_cmd_err:
Dim Msg As String
Msg = "Error Number " & Err.Number & ": " & Err.Description
exit_sub:
End Sub
I have a form (frmNewFamily) that is opened when a NotInList event is
triggered from a subform in a different form
(frmAttendance/sfrAttendee). I have a "Save" button on the frmNewFamily
that will save the record, close the frmNewFamily and requery the combo
boxes on sfrAttendee.
I have it working just great, but I want to delete one of the combo
boxes. But as soon as I comment out the requery line, the Save button
stops functioning properly. It will save the record to the table, but
not close the form or requery the combo box. The same thing happens if
I switch the two requery lines without commenting it out.
sfrAttendee has two combo boxes - CombinedName_cbo (which I want to
remove) and LastName_cbo, along with the control AtIndID, all of which
use the AtIndId as the Control Source. The combo boxes have different
Row Sources.
I've posted the code for the save button below. Can someone tell me why
how to delete the row in my code and the combo box without it causing my
save button to stop working? And, hopefully explain to me why it is
exhibiting this behavior. I'm trying to learn from my mistakes, but
this one has me stumped. :-(
Kathy R.
Private Sub SaveRec_cmd_Click()
On Error GoTo SaveRec_cmd_err
If IsNull(Me!sfrNewIndividual.Form.IndID) Then
MsgBox "Please place your cursor in the ""First Name"" field" & Chr$(13) & _
"of the individual you wish to add to the attendance form." _
, vbOKOnly, "CHOOSE SOMEONE!"
GoTo exit_sub:
End If
'saves new record
DoCmd.RunCommand acCmdSaveRecord
'commenting out the CombinedName_cbo.Requery line or switching
'the CombinedName line with the LastName line causes
'the Save button to save the record, but not requery the subform.
Forms!frmAttendance!sfrAttendee.Form.CombinedName_cbo.Requery
Forms!frmAttendance!sfrAttendee.Form.LastName_cbo.Requery
Forms!frmAttendance!MemberList_lst.Requery
'fills in the new info on sfrAttendee
Forms!frmAttendance!sfrAttendee.Form.AtIndID =
Forms!frmNewFamily.sfrNewIndividual.Form.IndID
'closes frmNewFamily
DoCmd.Close
SaveRec_cmd_err:
Dim Msg As String
Msg = "Error Number " & Err.Number & ": " & Err.Description
exit_sub:
End Sub