Problem using DMax with other criteria (1 Viewer)

109bow

Registered User.
Local time
Today, 16:41
Joined
Oct 24, 2007
Messages
134
I have a database that is used to track wheels fitted to trains. each train has 32 wheels.
At present I have 32 queries that give me the data for each wheel position in a particular train, I then have a further 32 queries that use the DMax function to return the last record for each wheel in the train.
Although this method works, it seems very long winded and slow.
I have tried to use the DMax function in the first set of queries but I either get no record returned or a message "Unknown" which then freezes Access.
The in my db the table DATAEXPORT_5 is a linked table, so I am unable to edit or manipulate table.
I would be grateful if anyone could "show me light" with this puzzle.
DB attached.
Many thanks
 

Attachments

  • sample.zip
    916.6 KB · Views: 97

jdraw

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Jan 23, 2006
Messages
15,379
Please add a little more detail to your requirement. Can you step back a give us the 30,000 ft view using simple plain English. Readers don't know you or your environment, so please help us with context.
What exactly is a "train"?
Are wheels all similar (size etc)? So any wheel could be fitted to any position?
 

109bow

Registered User.
Local time
Today, 16:41
Joined
Oct 24, 2007
Messages
134
jdraw, thanks for your reply.
As an overview, I work for an underground train system, where part of my job is to be able track and monitor wheels fitted to any train in the fleet. Each train consists of two units, and north end and a south end. North end units are numbered 02 up to 94 and are even numbers. South end units are numbered from 01 to 93 and are odd numbers. Each unit is made of 4 cars, numbered 110**, 120**, 130** and 140**. Each car has 4 wheels fitted to it and are numbered 1, 2, 3 and 4. So a particular wheelset position in a particular train can be identified as 11002-1.
Every wheel in the fleet has a unique serial number, it size at this point is so relevant as we monitor wheels based on the number of kilometers it has covered.
In my db I have front page 2, where I enter the unit numbers from 2 combo boxes. As there are 32 wheels fitted to a train, I have 32 queries which give me the data for each wheel position, ie. 11002-1, 11002-2, 11002-3, 11002-4, 12002-1 etc.
Then using DMax, a following 32 queries then give me the last record for each wheel position.
For instance, if units 02 and 01 are selected in front page 2, then query 110s1 is opened, there will be 4 records. I use query 110s1_lt to give me the last record based on Km.
I then use a union query to join 4 queries each car, 110s1_lt to 110s4_lt to get the last record for each wheel in a car.
Subform 110s last turn subform then displays the data.
Each wheel position has to be calculated separately as the Km for each position may be different, due to wheels being changed.
What I'm after is to reduce the number of queries for each wheel position from 2 to 1, to give the last record.
Hopes this explains, by feel I may have muddied the waters
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:41
Joined
Jan 23, 2006
Messages
15,379
Thanks for the info. I have a few questions that may be helpful???
A train makes a journey/travels a route, so you need to know
which train, which route, which date, which units, which cars and which wheels in order to determine the number of miles/kms a wheel has traveled.......??? Right?
Basically you need the Train configuration for each route/journey??

What are your data base tables and relationships? How often do you record data? That is what level of detail do you intend to use with this database?
 

109bow

Registered User.
Local time
Today, 16:41
Joined
Oct 24, 2007
Messages
134
thanks for your interest.
The original data comes from table DATAEXPORT_5 which in my database is a linked table. This table gives the km for a given wheel position on a particular date including wheel diameters.
As I tried to explain in my original post, all I am aiming to do is reduce the number of queries from 64 to 32.
 

gpgb

New member
Local time
Today, 08:41
Joined
Oct 18, 2012
Messages
8
Hi, I opened your sample database and was able to inspect your VBA, couldn't locate any DMAX constructs.

Did you solve your problem, if not I am sure I can assist
 

109bow

Registered User.
Local time
Today, 16:41
Joined
Oct 24, 2007
Messages
134
gpgb, thanks for your interest. I have now managed to resolved the problem by attacking it in different manner.
 

gpgb

New member
Local time
Today, 08:41
Joined
Oct 18, 2012
Messages
8
That's usually the way to solve a problem!

Drop me a line if you want a second opinion

Regards

Guy SE London
 

AccessBlaster

Registered User.
Local time
Today, 08:41
Joined
May 22, 2010
Messages
5,944
Looks to me like you designed a lot of queries, forms and reports before you normalized your tables.
 

Users who are viewing this thread

Top Bottom