473,396 Members | 1,689 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,396 software developers and data experts.

Need help with Query

I own a small business. Need to track a few hundred pieces of rental
equipment that can be in any of a few dozen locations. I'm an old-time C
language programmer (UNIX environment). If the only tool you know how to
use is a hammer, every problem tends to look like a nail. That said, I
could solve my problem in C, but it's not the right tool. I need to come
into the Windows world, and I need to get this done in Access or
something similar.

I have made a start in Access, and am making good progress, buy I'm
stymied by a query (or family of queries) that I will need.

I have defined two tables (over-simplified here): Eqpt and Loc for
attributes of the equipment and location, respectively. Primary Keys are
EqptID and LocID.

Since the equipment moves around between locations, I have a third table
with three attributes: EqptID, LocID, and EqLocDate. The date is the
date on which a piece of equipment was placed at a location. I need a
query for this third table.

1. Each piece of equipment will have multiple entries in this table. I
need to find the most recent (latest date) entry for each piece of
equipment. This can then be used to generate a report showing, for each
location, what equipment is currently at that location.

Can anyone help with that query?
Mar 29 '06 #1
10 2547
PCD
Your tables are excellent! Create a query that includes all three tables.
You need the first two to get the equipment name and the location name.
Include the following fields in your query:
EquipName, Locationname, EqLocDate. Click on the Sigma (looks liks capital
E) button in the toolbar at the top of the screen. Under EqLocDate, change
Group By to Max. Run the query and you should get an unique list of
equipment and its current location. Base your report on this query.

You haven't said anything about having a table to record equipment being
returned from rental. This will also need to be included in the above query
because the above query will list all equipment that has ever been rented
and will actually show where it was last rented although it may have been
returned.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1150 users have come to me from the newsgroups requesting help
re******@pcdatasheet.com

"L. R. Du Broff" <fo*@bar.com.invalid> wrote in message
news:Xn*****************@216.77.188.18...
I own a small business. Need to track a few hundred pieces of rental
equipment that can be in any of a few dozen locations. I'm an old-time C
language programmer (UNIX environment). If the only tool you know how to
use is a hammer, every problem tends to look like a nail. That said, I
could solve my problem in C, but it's not the right tool. I need to come
into the Windows world, and I need to get this done in Access or
something similar.

I have made a start in Access, and am making good progress, buy I'm
stymied by a query (or family of queries) that I will need.

I have defined two tables (over-simplified here): Eqpt and Loc for
attributes of the equipment and location, respectively. Primary Keys are
EqptID and LocID.

Since the equipment moves around between locations, I have a third table
with three attributes: EqptID, LocID, and EqLocDate. The date is the
date on which a piece of equipment was placed at a location. I need a
query for this third table.

1. Each piece of equipment will have multiple entries in this table. I
need to find the most recent (latest date) entry for each piece of
equipment. This can then be used to generate a report showing, for each
location, what equipment is currently at that location.

Can anyone help with that query?

Mar 29 '06 #2
PCD wrote:
Your tables are excellent! Create a query that includes all three tables.
You need the first two to get the equipment name and the location name.
Include the following fields in your query:
EquipName, Locationname, EqLocDate. Click on the Sigma (looks liks capital
E) button in the toolbar at the top of the screen. Under EqLocDate, change
Group By to Max. Run the query and you should get an unique list of
equipment and its current location. Base your report on this query.

You haven't said anything about having a table to record equipment being
returned from rental. This will also need to be included in the above query
because the above query will list all equipment that has ever been rented
and will actually show where it was last rented although it may have been
returned.

--
To anyone reading this thread:

It is commonly accepted that these newsgroups are for free
exchange of information. Please be aware that PC Datasheet
is a notorious job hunter. If you are considering doing
business with him then I suggest that you take a look at
the link below first.

http://home.tiscali.nl/arracom/whoissteve.html

Randy Harris
Mar 29 '06 #3
"L. R. Du Broff" <fo*@bar.com.invalid> wrote in
news:Xn*****************@216.77.188.18:
I own a small business. Need to track a few hundred pieces of
rental equipment that can be in any of a few dozen locations.
I'm an old-time C language programmer (UNIX environment). If
the only tool you know how to use is a hammer, every problem
tends to look like a nail. That said, I could solve my
problem in C, but it's not the right tool. I need to come
into the Windows world, and I need to get this done in Access
or something similar.

I have made a start in Access, and am making good progress,
buy I'm stymied by a query (or family of queries) that I will
need.

I have defined two tables (over-simplified here): Eqpt and
Loc for attributes of the equipment and location,
respectively. Primary Keys are EqptID and LocID.

Since the equipment moves around between locations, I have a
third table with three attributes: EqptID, LocID, and
EqLocDate. The date is the date on which a piece of equipment
was placed at a location. I need a query for this third
table.

1. Each piece of equipment will have multiple entries in this
table. I need to find the most recent (latest date) entry for
each piece of equipment. This can then be used to generate a
report showing, for each location, what equipment is currently
at that location.

Can anyone help with that query?

What you need is a query nested within another query

the inner one first. SELECT top 1 two.locID FROM [third table]
ALIAS two WHERE two.eqptid = eqpt.eqptID ORDER BY EqLocDate DESC

the outer query is
SELECT EqptID,(x) as CurrentLoc from eqpt ORDER BY CurrentLoc
where x is the inner query,

Nested you get
SELECT EqptID,(SELECT top 1 two.locID FROM [third table] ALIAS
two WHERE two.eqptid = eqpt.eqptID ORDER BY EqLocDate DESC) as
CurrentLoc from eqpt ORDER BY CurrentLoc; .

Change [third table] to the real name of your third table.

--
Bob Quintal

PA is y I've altered my email address.
Mar 29 '06 #4
"PCD" <no***@email.com> wrote in
news:lC******************@newsread3.news.atl.earth link.net:
Your tables are excellent! Create a query that includes all
three tables. You need the first two to get the equipment name
and the location name. Include the following fields in your
query: EquipName, Locationname, EqLocDate. Click on the Sigma
(looks liks capital E) button in the toolbar at the top of the
screen. Under EqLocDate, change Group By to Max. Run the query
and you should get an unique list of equipment and its current
location. Base your report on this query.
Again, PCD posts incorrect information. Doing this will return
the maximum of EqLocDate for each piece of equipment at each
location., because of the group by under the location.
You haven't said anything about having a table to record
equipment being returned from rental. This will also need to
be included in the above query because the above query will
list all equipment that has ever been rented and will actually
show where it was last rented although it may have been
returned.


That's not necessary, as the equipment not rented out is in
location "Rental Shop"

--
Bob Quintal

PA is y I've altered my email address.
Mar 29 '06 #5
"PCD" <no***@email.com> wrote in
news:lC******************@newsread3.news.atl.earth link.net:
You haven't said anything about having a table to record equipment
being returned from rental. This will also need to be included in the
above query because the above query will list all equipment that has
ever been rented and will actually show where it was last rented
although it may have been returned.


Not trying to track individual rentals (that's handled separately). What
I need to track is the location where a piece of equipment is currently
assigned, or based. Scenario is, place a piece of equipment a Location
A, where it does it's rental thing for a while. At some point, that
piece of equipment is returned to the warehouse (location 'W') for
service. After being serviced, it becomes a spare, then when needed, it
goes to location B for rental. If you imagine this cycle with a few
hundred pieces of equipment and a few dozen rental locations, it becomes
important to be able to track where each piece of equipment is based.

We visit each rental location at least once a month, and the first thing
we need to do upon arrival is to do a physical inventory of the equipment
at that location. We need to be able to flag missing equipment
accurately, and without false alarms. We have been using spreadsheets to
make the equipment list, but it's obvious that an Access solution is far
better for this task. The spreadsheets are inherited -- bought the
business from someone who had hired a computer "expert" to organize this,
and the "expert consultant" did it with Excel, which leaves a lot to be
desired for this task.
Mar 29 '06 #6
"L. R. Du Broff" <fo*@bar.com.invalid> wrote in message
news:Xn*****************@216.77.188.18...
"PCD" <no***@email.com> wrote in
news:lC******************@newsread3.news.atl.earth link.net:
The spreadsheets are inherited -- bought the
business from someone who had hired a computer "expert" to organize this,
and the "expert consultant" did it with Excel, which leaves a lot to be
desired for this task.


Was his name Steve and were his fees very reasonable?

;-)

Keith.
Mar 29 '06 #7
"Keith Wilby" <he**@there.com> wrote in
news:44**********@glkas0286.greenlnk.net:
"L. R. Du Broff" <fo*@bar.com.invalid> wrote in message
news:Xn*****************@216.77.188.18...
"PCD" <no***@email.com> wrote in
news:lC******************@newsread3.news.atl.earth link.net:
The spreadsheets are inherited -- bought the
business from someone who had hired a computer "expert" to organize
this, and the "expert consultant" did it with Excel, which leaves a
lot to be desired for this task.


Was his name Steve and were his fees very reasonable?

;-)

Keith.


Don't know his name, but I'm told that his expertise was available for
$10.00 (that's TEN) dollars an hour.
Mar 29 '06 #8
"L. R. Du Broff" <fo*@bar.com.invalid> wrote in message
news:Xn*****************@216.77.188.18...
"Keith Wilby" <he**@there.com> wrote in
news:44**********@glkas0286.greenlnk.net:
Was his name Steve and were his fees very reasonable?


Don't know his name, but I'm told that his expertise was available for
$10.00 (that's TEN) dollars an hour.


Sorry, it was a bit of an in-joke at the expense of a regular AUP-breaker on
here. :-)

Keith.
Mar 29 '06 #9
"L. R. Du Broff" wrote
the "expert consultant" did it with Excel, which leaves a
lot to be desired for this task.

Was his name Steve and were his fees very reasonable?


Don't know his name, but I'm told that his expertise
was available for $10.00 (that's TEN) dollars an hour.


<SARCASM> What a wonderful bargain! I can't even get my lawn mowed for
$10.00 (that's TEN) dollars an hour. </SARCASM>

<VOICE OF EXPERIENCE> Beware any who represent themselves as "expert" and
offer to sell their expertise for $10.00 per hour. </VOICE OF EXPERIENCE>

Larry Linson
Microsoft Access MVP
Mar 30 '06 #10
The previous owner hired Arno R as an "Expert" and the previous owner
learned the hardway about Arno R!

PC D

"L. R. Du Broff" <fo*@bar.com.invalid> wrote in message
news:Xn*****************@216.77.188.18...
"Keith Wilby" <he**@there.com> wrote in
news:44**********@glkas0286.greenlnk.net:
"L. R. Du Broff" <fo*@bar.com.invalid> wrote in message
news:Xn*****************@216.77.188.18...
"PCD" <no***@email.com> wrote in
news:lC******************@newsread3.news.atl.earth link.net:
The spreadsheets are inherited -- bought the
business from someone who had hired a computer "expert" to organize
this, and the "expert consultant" did it with Excel, which leaves a
lot to be desired for this task.


Was his name Steve and were his fees very reasonable?

;-)

Keith.


Don't know his name, but I'm told that his expertise was available for
$10.00 (that's TEN) dollars an hour.

Mar 31 '06 #11

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

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
6
by: paii | last post by:
I have a table that stores job milestone dates. The 2 milestones I am interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18. All jobs have TypeID 1 only some jobs have TypeID 18....
3
by: pw | last post by:
Hi, I am having a mental block trying to figure out how to code this. Two tables: "tblQuestions" (fields = quesnum, questype, question) "tblAnswers" (fields = clientnum, quesnum, questype,...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
7
by: Rnykster | last post by:
I know a little about Access and have made several single table databases. Been struggling for about a month to do a multiple table database with no success. Help! There are two tables. First...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.