A10Instructor
Technical User
Hi,
I've been struggling with this for several days and can no longer think straight.
I have a table called personnel. I created a form with a subform to edit the records of table persoonel. The main form has a combo box and the sub form has textboxes that correspond to the table.
When the main form is first opened, the combo box is blank and so are the Text boxes in the subform. When I select an individual in the combo box, its info is displayed in the subform for editing.
Here is where I'm having problems. After making the changes, I have the user click on a command button that saves the record and closes the form/subform via the on-click property. Within that coding, I have a msgbox appear asking if the user wants to edit another record. If answer is NO, switchboard is opened. If answer is YES, form/subform is reopened. The combo box is reset to blank, but the subform still displays the record previously viewed.
I can't figure it out....anyone have any ideas?
Heres the code:
Main form --
Sub SetFilter()
Dim LSQL As String
LSQL = "select * from personnel"
LSQL = LSQL & " where last = '" & cboSelected & "'"
Form_Editpersonnel_sub.RecordSource = LSQL
End Sub
Private Sub cboSelected_AfterUpdate()
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
Private Sub Form_Open(Cancel As Integer)
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
SUB-Form save button--
Private Sub SAVE_Click()
On Error GoTo Err_SAVE_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.close
If MsgBox("You have updated information on a Detachment Member. Do you wish to update another member?", vbExclamation + vbYesNo + vbDefaultButton2, "WARNING") = vbNo Then
DoCmd.OpenForm "PERSONNEL MANAGEMENT"
Else
DoCmd.OpenForm "Edit personnel"
End If
Exit_SAVE_Click:
Exit Sub
Err_SAVE_Click:
MsgBox Err.Description
Resume Exit_SAVE_Click
End Sub
I've been struggling with this for several days and can no longer think straight.
I have a table called personnel. I created a form with a subform to edit the records of table persoonel. The main form has a combo box and the sub form has textboxes that correspond to the table.
When the main form is first opened, the combo box is blank and so are the Text boxes in the subform. When I select an individual in the combo box, its info is displayed in the subform for editing.
Here is where I'm having problems. After making the changes, I have the user click on a command button that saves the record and closes the form/subform via the on-click property. Within that coding, I have a msgbox appear asking if the user wants to edit another record. If answer is NO, switchboard is opened. If answer is YES, form/subform is reopened. The combo box is reset to blank, but the subform still displays the record previously viewed.
I can't figure it out....anyone have any ideas?
Heres the code:
Main form --
Sub SetFilter()
Dim LSQL As String
LSQL = "select * from personnel"
LSQL = LSQL & " where last = '" & cboSelected & "'"
Form_Editpersonnel_sub.RecordSource = LSQL
End Sub
Private Sub cboSelected_AfterUpdate()
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
Private Sub Form_Open(Cancel As Integer)
'Call subroutine to set filter based on selected last name
SetFilter
End Sub
SUB-Form save button--
Private Sub SAVE_Click()
On Error GoTo Err_SAVE_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.close
If MsgBox("You have updated information on a Detachment Member. Do you wish to update another member?", vbExclamation + vbYesNo + vbDefaultButton2, "WARNING") = vbNo Then
DoCmd.OpenForm "PERSONNEL MANAGEMENT"
Else
DoCmd.OpenForm "Edit personnel"
End If
Exit_SAVE_Click:
Exit Sub
Err_SAVE_Click:
MsgBox Err.Description
Resume Exit_SAVE_Click
End Sub