473,675 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Order by dlookup in query

I'm usually strongly opposed to using dlookup in queries, but I need
this query to be updatable, so adding a subquery isnt an option. The
dlookup works fine except, I need to sort the results based on the
returned values. This doesnt work. Here's what I have (names changed to
protect the innocent!):

SELECT
tblx.x,
tblx.y,
tblx.z,
DLookUp("LastOf FieldA,"qryA","[Fieldx]= '" & tblx.x & "'") AS Result
FROM tblx
ORDER BY DLookUp("LastOf FieldA,"qryA","[Fieldx]= '" & tblx.x & "'")

If anyone has any ideas how to force the results to be returned in
order of the 'Result' field, please let me know... I have a feeling
there's a simple solution eluding me and it's starting to do my head
in!!!

Thanks!

Nov 13 '05 #1
3 6604
Update:
Ok, I've just realised that does actually kind of work - but the
problem is that the returned value is a date field and the sorting is
done alphabetical... I cant force the field to be recognised as a date
and sort the results properly. Changing the format in the frield
properties to "dd/mm/yyy" doesnt work. Any ideas?

Nov 13 '05 #2
Update 2:

Ok, solution found but it ain't pretty:

ORDER BY
format(DLookUp( "LastOfFieldA," qryA","[Fieldx]= '" & tblx.x & "'"),
"yyyy"),
format(DLookUp( "LastOfFieldA," qryA","[Fieldx]= '" & tblx.x & "'"),
"mm"),
format(DLookUp( "LastOfFieldA," qryA","[Fieldx]= '" & tblx.x & "'"),
"dd")

Any more elegant solutions would be greatefully recieved

Nov 13 '05 #3
How about using the CDate Function? This function attempts to convert
it's arguments into a date which you can sort on.

ORDER BY CDate(Fieldx)

Good luck
BillCo wrote:
Update 2:

Ok, solution found but it ain't pretty:

ORDER BY
format(DLookUp( "LastOfFieldA," qryA","[Fieldx]= '" & tblx.x & "'"),
"yyyy"),
format(DLookUp( "LastOfFieldA," qryA","[Fieldx]= '" & tblx.x & "'"),
"mm"),
format(DLookUp( "LastOfFieldA," qryA","[Fieldx]= '" & tblx.x & "'"),
"dd")

Any more elegant solutions would be greatefully recieved


Nov 13 '05 #4

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

Similar topics

1
20780
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one site could have many units. How do I have the DLookUp field value change to a newly calcuated field when I navigate through the units? please see example below: On the Form: A site can have many units.
3
2500
by: DFS | last post by:
FYI, Using DLookup("ResultsField","Pass-thru query") consumes 2 SEQUENCE numbers each time it's called. Anyone know why?
7
2253
by: Tony Williams | last post by:
Does DLookup work in an expression in a query? I have this expression -(DLookUp("","tblmaintabs","= ")) Which works fine as a calculated control on a form but when I try to use it in a query as an expression I don't get any result. I want to use the Sum of the result in a query on which I will base a report. TIA Tony
8
4317
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb Klms Distance Jones Melbourne 500 Harrison Sydney 200 Ford Brisbane 700 Jones ...
2
5068
by: bobabooey2k | last post by:
I have an update query with one field having in its "Update to" cell a DLookup statement. This query takes 2-3 minutes on 3000 records. Can I avoid dlookup here using multiple queries? An underlying subquery to this Update query involves a MAX function on a date field, which is then used in the DLookup statement. Any help appreciated. Thanks Richard
1
2420
by: MLH | last post by:
I have a query that looks up records in tblReturnReceipts and other related tables. One of the other tables is tblCorrespondence. The resulting dynaset consists of five records. Each has a unique field value and each has a unique field value. I would like to add an additional field to the query that performs a DLookup for some other stuff - using the query's value in the DLookup's criteria section. Of course, I'm having difficulty...
30
7264
by: DH22 | last post by:
Access 03 I'm currently having an issue using Dlookup when trying to reference a query (criteria syntax) Currently I have 1 table, which is L_Emps (which contains Employee_ID as my key (numeric), First_Name, and Last_Name (as text). My query is Query1 which is the following: SELECT L_Emps.Employee_ID, L_Emps.First_Name, L_Emps.Last_Name FROM L_Emps
3
1389
by: Demosthenis | last post by:
Hello, I am trying to seto up a Dlookup in a query. My Dlookup field will retrieve data from a second query. The match criteria is the W field. This dlookup up process has to retrieve 24 different values from the second query (Query5). Unfortunatelly the function always brings the first value of the 2nd query for all the 24 fields. My formula is the Expr10: IIf(="Stock4";dLookUp("SumOfExpr2";"Query5";"=" & ".");). Is it something...
3
9057
by: Kunal Desale | last post by:
Hello, I am migrating access queries to SQL Server 2005 Queries. My Access Query Is: SELECT qtrade.intordreftrim AS Expr1, qtrade.extordreftrim AS Expr2, qtrade.intinvreftrim AS Expr3, DLookUp("",""," = " & 4 & "and ='" & & "'") AS InvNoLookup, qtrade.invline AS Expr4, qtrade.accountid AS Expr5, qtrade.descriptn AS Expr6, DLookUp("",""," = " & 0 & "and ='" & & "'") AS , qtrade.qtyinv AS Expr7, qtrade.invdate AS Expr8, qtrade.amtuchg...
0
8521
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8973
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8868
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8722
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4468
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.