N
NEWER USER
I have a main form with a subform. On the main form is a command button that
opens a pop-up form with unbound fields. I use these fields as Search fields
to build a SQL and apply it as the recordsource of the subform The following
codes works well and fast. I want to use the pop-up form on several other
main forms that contain the same subform as the first. How do I reference
the form that is active when the pop-up form was called so I don't have to
create several pop-up forms only to change the main form reference in the
code?
Private Sub cmdAFilter_Click()
Dim strSQL As String
strSQL = "Select * from qryProduct where ProductID > 0 "
If Not IsNull(Me.txtOE) Then
strSQL = strSQL & " AND [NumberID] like '*" & Me.txtOE & "*'"
End If
If Not IsNull(Me.txtIMC) Then
strSQL = strSQL & " AND [JNumberID] like '*" & Me.txtIMC & "*'"
End If
If Not IsNull(Me.txtDesc) Then
strSQL = strSQL & " AND [SDescription] like '*" & Me.txtDesc & "*'"
End If
If Not IsNull(Me.txtBrand) Then
strSQL = strSQL & " AND [Brand] like '*" & Me.txtBrand & "*'"
End If
If Not IsNull(Me.txtRegion) Then
strSQL = strSQL & " AND tblType.[Make] like '*" & Me.txtRegion & "*'"
End If
If Not IsNull(Me.txtMfg) Then
strSQL = strSQL & " AND [Mfg] like '*" & Me.txtMfg & "*'"
End If
If Not IsNull(Me.txtNotes) Then
strSQL = strSQL & " AND [Notes] like '*" & Me.txtNotes & "*'"
End If
If Not IsNull(Me.txtClass) Then
strSQL = strSQL & " AND
opens a pop-up form with unbound fields. I use these fields as Search fields
to build a SQL and apply it as the recordsource of the subform The following
codes works well and fast. I want to use the pop-up form on several other
main forms that contain the same subform as the first. How do I reference
the form that is active when the pop-up form was called so I don't have to
create several pop-up forms only to change the main form reference in the
code?
Private Sub cmdAFilter_Click()
Dim strSQL As String
strSQL = "Select * from qryProduct where ProductID > 0 "
If Not IsNull(Me.txtOE) Then
strSQL = strSQL & " AND [NumberID] like '*" & Me.txtOE & "*'"
End If
If Not IsNull(Me.txtIMC) Then
strSQL = strSQL & " AND [JNumberID] like '*" & Me.txtIMC & "*'"
End If
If Not IsNull(Me.txtDesc) Then
strSQL = strSQL & " AND [SDescription] like '*" & Me.txtDesc & "*'"
End If
If Not IsNull(Me.txtBrand) Then
strSQL = strSQL & " AND [Brand] like '*" & Me.txtBrand & "*'"
End If
If Not IsNull(Me.txtRegion) Then
strSQL = strSQL & " AND tblType.[Make] like '*" & Me.txtRegion & "*'"
End If
If Not IsNull(Me.txtMfg) Then
strSQL = strSQL & " AND [Mfg] like '*" & Me.txtMfg & "*'"
End If
If Not IsNull(Me.txtNotes) Then
strSQL = strSQL & " AND [Notes] like '*" & Me.txtNotes & "*'"
End If
If Not IsNull(Me.txtClass) Then
strSQL = strSQL & " AND
Code:
like '*" & Me.txtClass & "*'"
End If
If Not IsNull(Me.txtMover) Then
strSQL = strSQL & " AND [CO] like '*" & Me.txtMover & "*'"
End If
If Not IsNull(Me.txtGroup) Then
strSQL = strSQL & " AND [PrdGroup] like '*" & Me.txtGroup & "*'"
End If
Forms!frmProduct!fsubNumbers.Form.RecordSource = strSQL
DoCmd.Close acForm, Me.Name
Forms!frmProduct!fsubNumbers.SetFocus
End Sub
I have other forms named
frmProductSync
frmOrderEntry
frmAlternates