I'm trying to provide the criteria for a query via a function, only because I could not get the like(isnull(iff statement to work properly. I have a form where the users select specific filter criteria for a report, I then read the forms data and pass the value to a query.
[CODE ]
Function FilterCompanyCode() As String
If IsNull(Forms!frmReports.cboEntity) Then
FilterCompanyCode = "Is Null Or """" Or Like ""*"""
Else
FilterCompanyCode = [Forms]![frmReports].[cboEntity]
End If
End Function
[/ CODE]
The FilterCompanyCode() is in the queries criteria. When the value in the combobox is not null the query returns the desired records. When the combobox is null the query does not return any records. When I step through the function and copy the variable directly to the query, it returns the proper recordset.
Anyone have any ideas why it wont work while running the function but does work when copied into the criteria of the query. Any help is greatly appreciated.
[CODE ]
Function FilterCompanyCode() As String
If IsNull(Forms!frmReports.cboEntity) Then
FilterCompanyCode = "Is Null Or """" Or Like ""*"""
Else
FilterCompanyCode = [Forms]![frmReports].[cboEntity]
End If
End Function
[/ CODE]
The FilterCompanyCode() is in the queries criteria. When the value in the combobox is not null the query returns the desired records. When the combobox is null the query does not return any records. When I step through the function and copy the variable directly to the query, it returns the proper recordset.
Anyone have any ideas why it wont work while running the function but does work when copied into the criteria of the query. Any help is greatly appreciated.
Last edited: