Connecting Tech Pros Worldwide Forums | Help | Site Map

A97 table design?

MLH
Guest
 
Posts: n/a
#1: Nov 13 '05
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?

Allen Browne
Guest
 
Posts: n/a
#2: Nov 13 '05

re: A97 table design?


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" <CRCI@NorthState.net> wrote in message
news:2lghf1dbf2p1srrclcv7eo4hr7cf1o5qeb@4ax.com...[color=blue]
> 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?[/color]


David W. Fenton
Guest
 
Posts: n/a
#3: Nov 13 '05

re: A97 table design?


"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in
news:42f8c5b4$0$32227$5a62ac22@per-qv1-newsreader-01.iinet.net.au:
[color=blue]
> 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[/color]

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
Allen Browne
Guest
 
Posts: n/a
#4: Nov 13 '05

re: A97 table design?


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" <dXXXfenton@bway.net.invalid> wrote in message
news:Xns96ADAC114576dfentonbwaynetinvali@216.196.9 7.142...[color=blue]
> "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in
> news:42f8c5b4$0$32227$5a62ac22@per-qv1-newsreader-01.iinet.net.au:
>[color=green]
>> 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[/color]
>
> 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?[/color]


Trevor Best
Guest
 
Posts: n/a
#5: Nov 13 '05

re: A97 table design?


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

my tLookup can do the same, e.g.

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

;-)
Allen Browne
Guest
 
Posts: n/a
#6: Nov 13 '05

re: A97 table design?


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" <nospam@nospam.invalid> wrote in message
news:42f9aa7f$0$21186$db0fefd9@news.zen.co.uk...[color=blue]
> Allen Browne wrote:[color=green]
>> Actually, that looks incredibly obvious to me, as the arguments match
>> your basic SQL statement:
>> SELECT Arg1 FROM Arg2 [WHERE Arg3] [ORDER BY Arg4]
>>[/color]
>
> my tLookup can do the same, e.g.
>
> tLookup("field","table","field2='whatever' order by field3 desc")
>
> ;-)[/color]


Trevor Best
Guest
 
Posts: n/a
#7: Nov 13 '05

re: A97 table design?


Allen Browne wrote:[color=blue]
> 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. :-)
>[/color]

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 :-)
Closed Thread