Autofill field? (1 Viewer)

jordsta95

Registered User.
Local time
Today, 15:25
Joined
Nov 25, 2013
Messages
10
Hey guys, this probably has a simple solution but I have no idea how to fix it :(

What I want to do is have a macro run a query (which I have no issue on doing) but then have the query display the result from the latest record.

-If that made no sense:
I have a query which has multiple fields (all of which fill) and one of those fields is ServerID.
So instead of having to add [insert ServerID] (or something) I would like it to do something like the Date() function, but for the most recent ServerID and all related fields.

If you need anything clarifying just ask :)
Thanks for your help
-Jordan
 

namliam

The Mailman - AWF VIP
Local time
Today, 16:25
Joined
Aug 11, 2003
Messages
11,695
are you looking for the DMax function?
Or select Max(ServerID) from yourtable
??
 

jordsta95

Registered User.
Local time
Today, 15:25
Joined
Nov 25, 2013
Messages
10
I don't know :/

I tried both of the expressions and neither worked.

Unless I am a complete idiot, here is what I did/have:
I have a few fields in a query, one being ServerID
In the criteria I put Max(ServerID) - Which it changed to Max([ServerID])
But that didn't work

So I put in DMax, but I have no idea what to put in as expression etc.
 

namliam

The Mailman - AWF VIP
Local time
Today, 16:25
Joined
Aug 11, 2003
Messages
11,695
You want to only retrieve the maximum or most recent ServerID...
for what purpose?
Where do you intend to use it for?
Is this field a number field?
Is this field an AUTO number field?

Edit: Dmax is something you would probably be using if your using VBA, where as the Select Max() you would use in a query... but you would use it as I described it, getting rid of all the other fields.
 

RainLover

VIP From a land downunder
Local time
Tomorrow, 00:25
Joined
Jan 5, 2009
Messages
5,041
Jordan

What makes a record the latest. I ask this because a Table does not guarantee to show its Data in the same order every time.

Try sorting the table then close and save it. Reopen and try a different sort. You should see what I mean.
 

jordsta95

Registered User.
Local time
Today, 15:25
Joined
Nov 25, 2013
Messages
10
You want to only retrieve the maximum or most recent ServerID...
for what purpose?
Where do you intend to use it for?
Is this field a number field?
Is this field an AUTO number field?

Edit: Dmax is something you would probably be using if your using VBA, where as the Select Max() you would use in a query... but you would use it as I described it, getting rid of all the other fields.

Yes it is an Auto Number field, and I am trying to get it to display the latest number in that field
 

RainLover

VIP From a land downunder
Local time
Tomorrow, 00:25
Joined
Jan 5, 2009
Messages
5,041
I may be off track here. I have posted an Access 2003 DB that has two non related queries. qryRainSampleShowAll shows all records while qryRainSample only shows the record with the highest Primary Key.

You could use the sample shown to apply it to other fields.

The posted Database is to use the expression DMax plus One on different animals. You may be able to apply this to something.
 
Last edited:

RainLover

VIP From a land downunder
Local time
Tomorrow, 00:25
Joined
Jan 5, 2009
Messages
5,041
I had a problem with the attachment.

I have therefore reattached a new one.
 

Attachments

  • AWF DMax.mdb
    340 KB · Views: 115
Last edited:

Users who are viewing this thread

Top Bottom