473,385 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Query Grid with two Criteria

I need to write a query that has a criteria of two separate fields (one
compared to another, then a seperate one) but I can't figure out how
to do it. Let me first explain the table

id (primary ID)
FirstName (text)
LastName (text)
BadgeIn (text)
BadgeOut (text)
Damaged (yes/no)
What I what to do is check if BadgeIn is equal to Badge Out, if not I
want to retrieve the record. I also want to retrieve the record if
BadgeIn DOES match Badge Out, but only if Damage is true (checked).

So
BadgeIn = BadgeOut , Damaged = False - Skip Record
Badge <BadgeOut , Damaged = False - Retrieve Record
Badge <BadgeOut , Damage = True - Retrieve Record
Badge = BadgeOut, Damage = True - Retrieve record.

Im not sure how to go about this. Im guessing an If Statement but I
have never seend one in a query window. I googled for some examples
but counldnt find any like this.

Thanks,

Dave

Dec 29 '06 #1
3 1809

st********@hotmail.com wrote:
I need to write a query that has a criteria of two separate fields (one
compared to another, then a seperate one) but I can't figure out how
to do it. Let me first explain the table

id (primary ID)
FirstName (text)
LastName (text)
BadgeIn (text)
BadgeOut (text)
Damaged (yes/no)
What I what to do is check if BadgeIn is equal to Badge Out, if not I
want to retrieve the record. I also want to retrieve the record if
BadgeIn DOES match Badge Out, but only if Damage is true (checked).

So
BadgeIn = BadgeOut , Damaged = False - Skip Record
Badge <BadgeOut , Damaged = False - Retrieve Record
Badge <BadgeOut , Damage = True - Retrieve Record
Badge = BadgeOut, Damage = True - Retrieve record.

Im not sure how to go about this. Im guessing an If Statement but I
have never seend one in a query window. I googled for some examples
but counldnt find any like this.

Thanks,

Dave
so what's the problem? just put your criteria on multiple lines. And
leave out the false criteria. They won't help you.

So
BadgeIn<>BadgeOut AND Damaged=False OR
Badge<>BadgeOut AND Damaged=True OR
Badge=BadgeOut AND Damaged=True

actually, since Damaged can only be T/F, you don't need them in the
first two statements.

BadgeIn<>BadgeOut OR
Badge<>BadgeOut OR
Badge=BadgeOut AND Damaged=True

Dec 29 '06 #2
Do I create an expression in a new column then put this in the
creiteria? I guess that is where I am confused. Im new(er) to access.
pi********@hotmail.com wrote:
st********@hotmail.com wrote:
I need to write a query that has a criteria of two separate fields (one
compared to another, then a seperate one) but I can't figure out how
to do it. Let me first explain the table

id (primary ID)
FirstName (text)
LastName (text)
BadgeIn (text)
BadgeOut (text)
Damaged (yes/no)
What I what to do is check if BadgeIn is equal to Badge Out, if not I
want to retrieve the record. I also want to retrieve the record if
BadgeIn DOES match Badge Out, but only if Damage is true (checked).

So
BadgeIn = BadgeOut , Damaged = False - Skip Record
Badge <BadgeOut , Damaged = False - Retrieve Record
Badge <BadgeOut , Damage = True - Retrieve Record
Badge = BadgeOut, Damage = True - Retrieve record.

Im not sure how to go about this. Im guessing an If Statement but I
have never seend one in a query window. I googled for some examples
but counldnt find any like this.

Thanks,

Dave

so what's the problem? just put your criteria on multiple lines. And
leave out the false criteria. They won't help you.

So
BadgeIn<>BadgeOut AND Damaged=False OR
Badge<>BadgeOut AND Damaged=True OR
Badge=BadgeOut AND Damaged=True

actually, since Damaged can only be T/F, you don't need them in the
first two statements.

BadgeIn<>BadgeOut OR
Badge<>BadgeOut OR
Badge=BadgeOut AND Damaged=True
Dec 29 '06 #3
You got me on track!..

The way I got it to work was create an expression (new column ) in the
query

Match: [BadgeIn]<>[BadgeOut]
cretiera 0 = match and -1 = no match

then put the numbers in the "or" section of the critera to meet the
examples listed.

Is this the correct way of doing it?

st********@hotmail.com wrote:
Do I create an expression in a new column then put this in the
creiteria? I guess that is where I am confused. Im new(er) to access.
pi********@hotmail.com wrote:
st********@hotmail.com wrote:
I need to write a query that has a criteria of two separate fields (one
compared to another, then a seperate one) but I can't figure out how
to do it. Let me first explain the table
>
id (primary ID)
FirstName (text)
LastName (text)
BadgeIn (text)
BadgeOut (text)
Damaged (yes/no)
>
>
What I what to do is check if BadgeIn is equal to Badge Out, if not I
want to retrieve the record. I also want to retrieve the record if
BadgeIn DOES match Badge Out, but only if Damage is true (checked).
>
So
BadgeIn = BadgeOut , Damaged = False - Skip Record
Badge <BadgeOut , Damaged = False - Retrieve Record
Badge <BadgeOut , Damage = True - Retrieve Record
Badge = BadgeOut, Damage = True - Retrieve record.
>
Im not sure how to go about this. Im guessing an If Statement but I
have never seend one in a query window. I googled for some examples
but counldnt find any like this.
>
Thanks,
>
Dave
so what's the problem? just put your criteria on multiple lines. And
leave out the false criteria. They won't help you.

So
BadgeIn<>BadgeOut AND Damaged=False OR
Badge<>BadgeOut AND Damaged=True OR
Badge=BadgeOut AND Damaged=True

actually, since Damaged can only be T/F, you don't need them in the
first two statements.

BadgeIn<>BadgeOut OR
Badge<>BadgeOut OR
Badge=BadgeOut AND Damaged=True
Dec 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
2
by: Enterprise | last post by:
I'm stuck. I use Access 2000. I have a date field in a query. What I need done is if a Limit_Date function returns a true, I want the date field to be Between 1/1/02 and 1/1/03, otherwise I want it...
6
by: Andy | last post by:
Hello, I am having many problems with setting up a parameter query that searches by the criteria entered or returns all records if nothing is entered. I have designed an unbound form with 3...
2
by: Matthew | last post by:
Hey , I have built a query which takes values from unbounded fields on a form, and it all works except for one thing. I have a few fields in my query that are dates. I also have a start and...
1
by: Robert | last post by:
I am trying to create a db for service providers by county. I'm relatively new to db programming, but I have done quite a bit of programming ranging from the old basic days up to doing some...
4
by: Judy | last post by:
I'm using Access 2003 and was wondering if it is possible to have a paramater selection within a crosstab query so that I wouldn't need to build a new table. I have a select query that I'm using...
0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
3
by: MLH | last post by:
Am repeating question with different subject heading, perhaps stating more clearly my problem... I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
4
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.