I have a form that is meant to add a new facilitator to the FacilitatorTable. It can be opened directly from a menu page.
However, sometimes it will be opened from a form that is used to link facilitators to events that they facilitate. The combo box's row source is based on a query that is based on the FacilitatorTable. When a new facilitator is added, the query has to be refreshed for the name to appear in the combo box.
I have tied this requery to the VBA code in the "close" button on the new facilitator form. That part works great. The problem is that now, for some reason, the close part of the VBA isn't working. Here is what I have:
The DoCmd.Close line works fine when the If statement with the requery commands is removed. It also works fine when put before the requery commands, but that of course stops the entire VBA code and the requery commands aren't triggered.
Does anyone have any ideas? Thanks.
However, sometimes it will be opened from a form that is used to link facilitators to events that they facilitate. The combo box's row source is based on a query that is based on the FacilitatorTable. When a new facilitator is added, the query has to be refreshed for the name to appear in the combo box.
I have tied this requery to the VBA code in the "close" button on the new facilitator form. That part works great. The problem is that now, for some reason, the close part of the VBA isn't working. Here is what I have:
Code:
Private Sub CloseCmd_Click()
On Error GoTo errHandler
Dim CmdCloseMsg As String
CmdCloseMsg = MsgBox("Save new facilitator and close?", vbOKCancel + vbDefaultButton1, "Close form?")
If (CmdCloseMsg = vbOK) Then
DoCmd.RunCommand acCmdSaveRecord
'If this form was opened from the ZooMobile Ed Update form, EdFormTxt control is set to "ZM"
If Me.EdFormTxt = "ZM" Then
'Refreshes the facilitator combo list source in the subforms of the ZooMobile Ed Update form
DoCmd.Requery Forms![ZooMobile Eduction Update Form]!FacilitatorSubform.Form!DocentTxt
DoCmd.Requery Forms![ZooMobile Eduction Update Form]!ShadowSubform.Form!ShadowTxt
End If
DoCmd.Close acForm, "New Facilitator Form", acSaveNo
End If
errHandler:
If Err.Number = 2046 Then
Resume Next
End If
End Sub
The DoCmd.Close line works fine when the If statement with the requery commands is removed. It also works fine when put before the requery commands, but that of course stops the entire VBA code and the requery commands aren't triggered.
Does anyone have any ideas? Thanks.