I have a subform with a combo box with a not in list event that calls a data entry form. Closing the data entry form needs to include requerying the subform’s cboBox. The combo box could be on one of two subforms. I’m trying to save the name of the subform in a global variable called gstrSubformName and then refer to it in the Close event code but it’s not happening.
The basFormName includes:
Option Compare Database
Option Explicit
Public gstrSubformName As String
The subform’s Not In List code includes the following:
Dim gstrSubformName As String
gstrSubformName = Me.Name
The cmdClose on the data entry form is as follows:
Private Sub cmdClose_Click()
Dim frm As Form
Dim strFormName As String
Dim gstrSubformName As String
Dim lngCSZID As Integer
Set frm = Forms(gstrSubformName)
lngCSZID = Me![txtAddrHmID]
‘blnCanClose = True
DoCmd.Close acForm, Me.Name, acSaveNo
frm.Requery
frm![cboCSZID].Requery
frm.[cboCSZID] = lngCSZID
End Sub
I’m getting an error that it can’t find the form and the variable is an empty string. Where am I messing up? Can you tell from what I’ve posted?
E