F
fawilson
Hello all,
I have written the following function and I want to use it in the
criteria of a query. However, when placing "BaseFacility()" without
quotes in the [FAC_ID] field's criteria nothing is returned.
Please help. Thank you.
Fred
Function BaseFacility() As String
Dim frmReport As Form
Set frmReport = Forms("frmReports")
Dim dblBinary As Double
dblBinary = 0
If frmReport!cboFacility = "[All Facilities]" Then
If frmReport!chkMUTC = -1 Then dblBinary = dblBinary + 1
If frmReport!chkJSTEC = -1 Then dblBinary = dblBinary + 2
If frmReport!chkSTRENGTH = -1 Then dblBinary = dblBinary + 4
Select Case dblBinary
Case 0
BaseFacility = "Like '*'"
Case 1
BaseFacility = "Not like 'M_*'"
Case 2
BaseFacility = "Not like 'J_*'"
Case 3
BaseFacility = "Not like 'M_*' AND not like 'J_*' AND not
like '*STRENGTH*'"
Case 4
BaseFacility = "Not like '*STRENGTH*'"
Case 5
BaseFacility = "Not like 'M_*' AND not like '*STRENGTH*'"
Case 6
BaseFacility = "Not like 'J_*' AND not like '*STRENGTH*'"
Case 7
BaseFacility = "=Not like 'M_*' AND not like 'J_*' AND not
like '*STRENGTH*'"
End Select
Else
BaseFacility = frmReports!cboFacility
End If
End Function
I have written the following function and I want to use it in the
criteria of a query. However, when placing "BaseFacility()" without
quotes in the [FAC_ID] field's criteria nothing is returned.
Please help. Thank you.
Fred
Function BaseFacility() As String
Dim frmReport As Form
Set frmReport = Forms("frmReports")
Dim dblBinary As Double
dblBinary = 0
If frmReport!cboFacility = "[All Facilities]" Then
If frmReport!chkMUTC = -1 Then dblBinary = dblBinary + 1
If frmReport!chkJSTEC = -1 Then dblBinary = dblBinary + 2
If frmReport!chkSTRENGTH = -1 Then dblBinary = dblBinary + 4
Select Case dblBinary
Case 0
BaseFacility = "Like '*'"
Case 1
BaseFacility = "Not like 'M_*'"
Case 2
BaseFacility = "Not like 'J_*'"
Case 3
BaseFacility = "Not like 'M_*' AND not like 'J_*' AND not
like '*STRENGTH*'"
Case 4
BaseFacility = "Not like '*STRENGTH*'"
Case 5
BaseFacility = "Not like 'M_*' AND not like '*STRENGTH*'"
Case 6
BaseFacility = "Not like 'J_*' AND not like '*STRENGTH*'"
Case 7
BaseFacility = "=Not like 'M_*' AND not like 'J_*' AND not
like '*STRENGTH*'"
End Select
Else
BaseFacility = frmReports!cboFacility
End If
End Function