By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

Returnt he results of 2 boolean variables as one result

P: n/a
Hi All,

I did search for this before posting but I didn't find what I was looking for.
..

I have a function (returning boolean) that in turn calls 2 more functions
(also returning boolean). I know I could do an if statement to see if both
are true and return true, otherwise false, but I got to thinking and I
figured there must be a shorter way to do this.

I had thought maybe math:
result = result1 + result2
but this wouldn't work the way I had thought (True + True = True) - rather -
1 + -1 = -2

Then I thought about the DMAX function (return the largest of the data set):
DMAX (True, False) = false (0)
DMAX (True, True) = True (-1)

but I read all over the these function s aren't a good idea to use over
otheres, so I thought I'd post the question...

Thanks in advance,

Corey

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200610/1

Oct 16 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Corey-g via AccessMonster.com wrote:
Hi All,

I did search for this before posting but I didn't find what I was looking for.
.

I have a function (returning boolean) that in turn calls 2 more functions
(also returning boolean). I know I could do an if statement to see if both
are true and return true, otherwise false, but I got to thinking and I
figured there must be a shorter way to do this.
Function BothTrue(blnArg1 as boolean, blnArg2 as boolean) as boolean
BothTrue = blnArg1 And blnArg2
End Function

Oct 16 '06 #2

P: n/a
I knew that there awas a shorter way than an if statement.

Thanks so much!!!

Corey

--
Message posted via http://www.accessmonster.com

Oct 16 '06 #3

P: n/a
Corey,
if your function is simple, you would be better off doing the
calculation in a query. Only use functions if you have to. For
example, if your function can take varied parameters and has complex
business logic.

You could easily do something like this in a query:

SELECT Field1, Field2, (booleanField1 AND booleanField2) AS
ReturnBoolean
FROM SomeTable...

won't really matter that much when you have a small DB, but the bigger
you get, the more important it is to use the best/most efficient tool
available.

HTH,
Pieter

Oct 17 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.