G
Guest
Hello (again),
I'm attempting to pass a string of text to the Where Clause in a query via a
Public Function. Here's the code:
Public Function GetUAB() As String
Set ctrlUAB = [Forms]![frm_BasicStats]![cboUAB]
Set ctrlchkUAB = [Forms]![frm_BasicStats]![chkUAB]
If ctrlchkUAB = -1 And ctrlUAB = 1 Then
stUAB = "100 Or 101 Or 110 Or 111"
GetUAB = stUAB
ElseIf ctrlchkUAB = -1 And ctrlUAB = 2 Then
stUAB = "011 Or 010 Or 110 Or 111"
GetUAB = stUAB
ElseIf ctrlchkUAB = -1 And ctrlUAB = 3 Then
stUAB = "001 Or 101 Or 011 Or 111"
GetUAB = stUAB
ElseIf ctrlchkUAB = 0 Then
GetUAB = "000 Or 001 Or 010 Or 011 Or 100 Or 101 Or 110 Or 111"
End If
End Function
No matter what I do, the query doesn't return any records. It's OK if I
type each of the above strings into the criteria box but the 'GetUAB()'
function call doesn't go away and get the appropriate string automatically.
I've tried using a LongInteger instead of a string without any joy either. I
do hope you can help as I'm getting very frustrated with this now!!!![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
Kind Regards,
Lee
I'm attempting to pass a string of text to the Where Clause in a query via a
Public Function. Here's the code:
Public Function GetUAB() As String
Set ctrlUAB = [Forms]![frm_BasicStats]![cboUAB]
Set ctrlchkUAB = [Forms]![frm_BasicStats]![chkUAB]
If ctrlchkUAB = -1 And ctrlUAB = 1 Then
stUAB = "100 Or 101 Or 110 Or 111"
GetUAB = stUAB
ElseIf ctrlchkUAB = -1 And ctrlUAB = 2 Then
stUAB = "011 Or 010 Or 110 Or 111"
GetUAB = stUAB
ElseIf ctrlchkUAB = -1 And ctrlUAB = 3 Then
stUAB = "001 Or 101 Or 011 Or 111"
GetUAB = stUAB
ElseIf ctrlchkUAB = 0 Then
GetUAB = "000 Or 001 Or 010 Or 011 Or 100 Or 101 Or 110 Or 111"
End If
End Function
No matter what I do, the query doesn't return any records. It's OK if I
type each of the above strings into the criteria box but the 'GetUAB()'
function call doesn't go away and get the appropriate string automatically.
I've tried using a LongInteger instead of a string without any joy either. I
do hope you can help as I'm getting very frustrated with this now!!!
![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
Kind Regards,
Lee