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

A97 table design?

P: n/a
MLH
If I open an A97 table, resort its key-field to descending order and
attempt to close the table, A97 asks me if I wish to save the table
DESIGN? Now really, I don't think the table design is being saved
at all. If so, how does one explain these facts:

1) say I do click Yes to save the table design
2) later I open the table manually and, sure enough, key field is
shown in descending order
3) I run this in debug window... ?DLookup("[KeyField]", "MyTable")

Step 3 returns the value of the FIRST actual record ever entered
into the table - not the last. Obviously, if fundamental table DESIGN
had been saved as implied by the A97 prompt, the last would-a-been
shown. So, A97 is NOT saving a modified version of table design, is
it? Its merely saving a query filter sort. Sound about right?
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Only the table's OrderBy property is being saved.

By definition, records are unordered in a relational database. The fact that
Access presents them in primary key order by default is understandable, but
it is outside of what a relational database should do.

A major weakness with DLookup() is that you cannot specify a sort order,
i.e. you take pot luck as to which record is returned if there are multiple
matches. For an extended replacement of DLookup() that solves that problem
by letting you specify the retrieval order, see:
http://allenbrowne.com/ser-42.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthState.net> wrote in message
news:2l********************************@4ax.com...
If I open an A97 table, resort its key-field to descending order and
attempt to close the table, A97 asks me if I wish to save the table
DESIGN? Now really, I don't think the table design is being saved
at all. If so, how does one explain these facts:

1) say I do click Yes to save the table design
2) later I open the table manually and, sure enough, key field is
shown in descending order
3) I run this in debug window... ?DLookup("[KeyField]", "MyTable")

Step 3 returns the value of the FIRST actual record ever entered
into the table - not the last. Obviously, if fundamental table DESIGN
had been saved as implied by the A97 prompt, the last would-a-been
shown. So, A97 is NOT saving a modified version of table design, is
it? Its merely saving a query filter sort. Sound about right?

Nov 13 '05 #2

P: n/a
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:42***********************@per-qv1-newsreader-01.iinet.net.au:
A major weakness with DLookup() is that you cannot specify a sort
order, i.e. you take pot luck as to which record is returned if
there are multiple matches. For an extended replacement of
DLookup() that solves that problem by letting you specify the
retrieval order, see:
http://allenbrowne.com/ser-42.html


Pardon me, but isn't that a mis-use of DLookup(), to request
criteria that return more than one value? Isn't that really more
like a DFirst() function?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3

P: n/a
David, I'm sure you know that DLookup() will work where the return value is
non-unique, so I understand you to mean that it's not a sensible thing to do
since the return value is undefined/unreliable. Fair enough (though there
are certainly cases where it does make sense, e.g. get me an invoice for
client 54--I don't care which one.)

DFirst() doesn't solve the problem I'm addressing.
None of the domain aggregate functions can answer this:
What is the most recent InvoiceID for Client 54?
where "most recent" is defined by the InvoiceDate.

If we had an extra optional argument for DLookup() to specify the sort
order, you could do that easily:
DLookup("InvoiceID", "tblInvoice", "ClientID=54", "InvoiceDate DESC")
I actully requsted MS to add this feature, arguning that an optional extra
argument breaks no existing code, and would very useful. It didn't happen,
so I wrote a replacement function that does it.

Actually, that looks incredibly obvious to me, as the arguments match your
basic SQL statement:
SELECT Arg1 FROM Arg2 [WHERE Arg3] [ORDER BY Arg4]

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn*********************************@216.196.9 7.142...
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:42***********************@per-qv1-newsreader-01.iinet.net.au:
A major weakness with DLookup() is that you cannot specify a sort
order, i.e. you take pot luck as to which record is returned if
there are multiple matches. For an extended replacement of
DLookup() that solves that problem by letting you specify the
retrieval order, see:
http://allenbrowne.com/ser-42.html


Pardon me, but isn't that a mis-use of DLookup(), to request
criteria that return more than one value? Isn't that really more
like a DFirst() function?

Nov 13 '05 #4

P: n/a
Allen Browne wrote:
Actually, that looks incredibly obvious to me, as the arguments match your
basic SQL statement:
SELECT Arg1 FROM Arg2 [WHERE Arg3] [ORDER BY Arg4]


my tLookup can do the same, e.g.

tLookup("field","table","field2='whatever' order by field3 desc")

;-)
Nov 13 '05 #5

P: n/a
And yours has been around longer, Trevor.

BTW, you don't provide the link to your site in your sig?
Maybe that's what "Windows is searching" was all about. :-)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Trevor Best" <no****@nospam.invalid> wrote in message
news:42***********************@news.zen.co.uk...
Allen Browne wrote:
Actually, that looks incredibly obvious to me, as the arguments match
your basic SQL statement:
SELECT Arg1 FROM Arg2 [WHERE Arg3] [ORDER BY Arg4]


my tLookup can do the same, e.g.

tLookup("field","table","field2='whatever' order by field3 desc")

;-)

Nov 13 '05 #6

P: n/a
Allen Browne wrote:
And yours has been around longer, Trevor.

BTW, you don't provide the link to your site in your sig?
Maybe that's what "Windows is searching" was all about. :-)


What sig? <g>

My trusty old Soundblaster went pop and took Windows out with it so no
sig at all ATM until I get around to setting one up again.

I used to have a link about 7 years ago, about the time I last updated
the site :-)
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.