If statement for query help

Milothicus

Registered User.
Local time
Today, 11:22
Joined
Sep 24, 2004
Messages
134
I'm running a search query, and depending on the state of a check box. the check indicates wether or not a user wants 'lost jobs' (meaning bid not accepted) to be included in the search.
fLstSrch is in the criteria for the 'order lost' column in the search. it passes the value fine, and if it's 0, it works fine, but i can't get it to include all records.

I've tried:
"0 Or -1"
"=0 or = -1"
=0 or -1"
""
"*"

and others, i'm sure. i can't get it to work. any recommendations?

Public Function fLstSrch(optVal)
If optVal = 0 Then
fLstSrch = "0"
ElseIf optVal = -1 Then
fLstSrch = "0 Or -1"
End If
End Function
 
M,

Makes no sense to me ... need more info.

Your current function is returning a string!

Maybe this (but why not just use optval as a criteria?):

Code:
Public Function fLstSrch(optVal) As Boolean
If optVal = 0 Then
   fLstSrch = False
ElseIf optVal = True Then
   fLstSrch = True
End If
End Function

Wayne
 
It's returning a string because its output is used as a criterion for a query. i got it to work by making the second output "**". i have no idea why it works, but it does.

your code doesn't do what i need. if the checkbox is true, i want all records. if it's false, i want only the ones that are false.

also, i tried true and false and couldn't get them to work....but 0 is equivalent to false, and -1 is equivalant to true.
 
huhh - I thought
0 = false
and
1 = true
 
Milothicus said:
It's returning a string because its output is used as a criterion for a query. i got it to work by making the second output "**". i have no idea why it works, but it does.

your code doesn't do what i need. if the checkbox is true, i want all records. if it's false, i want only the ones that are false.

also, i tried true and false and couldn't get them to work....but 0 is equivalent to false, and -1 is equivalant to true.
I always find changing the forms record source in this instance is great if you need to put in a if statement.

try this:

if Checkbox.value = true then
me.recordsource = "YourSourceTableNameHere"

else
me.recordsource = "YourQueryNameHere"
end if

Does this help? Please respond
 

Users who are viewing this thread

Back
Top Bottom