Hello,
I have a form with a combo box (cboType_Selector). I need to pass the value of this box into another module to run a program to select the records specified in the combo box. The program runs fine if I keep both subs in the same module but I would like to keep them in separate modules so that I can re-use one of the subs for other programs. I am setting down the calling sub and then the called subs below.
CALLING SUB
Private Sub cboType_Selector_AfterUpdate()
TypeSelectRecords (Me.cboType_Selector, me.Name)
End Sub
CALLED SUB (in different module)
Public Sub TypeSelectRecords(strcboType_Selector As String, strForm_Name As String)
On Error GoTo Error_Handler
Dim varWhereClause As Variant
Dim strAND As String
varWhereClause = Null
strAND = " And "
If strcboType_Selector <> "<all>" Then
varWhereClause = (varWhereClause + strAND) & _
"tblAttachments.Type = """ & _
strcboType_Selector & """"
End If
varWhereClause = " WHERE " + varWhereClause
Forms(strForm_Name).RecordSource = ReplaceWhereClause(Forms(strForm_Name).RecordSource, varWhereClause)
Me.Requery
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox (Err.Number & ": " & Err.Description)
Resume Exit_Procedure
Resume
End Sub
In the calling sub, the compiler shows error - 'Expected ='. Could someone please help me transfer the variables on my form to the sub in a different module.
Thanks in advance and Merry Christmas.
Rudra
I have a form with a combo box (cboType_Selector). I need to pass the value of this box into another module to run a program to select the records specified in the combo box. The program runs fine if I keep both subs in the same module but I would like to keep them in separate modules so that I can re-use one of the subs for other programs. I am setting down the calling sub and then the called subs below.
CALLING SUB
Private Sub cboType_Selector_AfterUpdate()
TypeSelectRecords (Me.cboType_Selector, me.Name)
End Sub
CALLED SUB (in different module)
Public Sub TypeSelectRecords(strcboType_Selector As String, strForm_Name As String)
On Error GoTo Error_Handler
Dim varWhereClause As Variant
Dim strAND As String
varWhereClause = Null
strAND = " And "
If strcboType_Selector <> "<all>" Then
varWhereClause = (varWhereClause + strAND) & _
"tblAttachments.Type = """ & _
strcboType_Selector & """"
End If
varWhereClause = " WHERE " + varWhereClause
Forms(strForm_Name).RecordSource = ReplaceWhereClause(Forms(strForm_Name).RecordSource, varWhereClause)
Me.Requery
Exit_Procedure:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox (Err.Number & ": " & Err.Description)
Resume Exit_Procedure
Resume
End Sub
In the calling sub, the compiler shows error - 'Expected ='. Could someone please help me transfer the variables on my form to the sub in a different module.
Thanks in advance and Merry Christmas.
Rudra