DLookup Criteria Syntax (1 Viewer)

Lucky33

Registered User.
Local time
Today, 02:39
Joined
Sep 3, 2011
Messages
57
I want to thank both of you MajP and arnelgp for your efforts and for your help. I learned a lot from both of you today and I made it to the final line.
MajP gave me the idea to use the top values and I used arnel's code, with a little tweaking by creating a new query with max dates, narrowing down the search and eliminating whatever is happening in the back giving erroneous results. After creating the new query, all I had to do is to change the name of the query in the code. Case closed
Again thank you both for all the efforts and help
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:39
Joined
May 7, 2009
Messages
19,169
Good to know you have a working solution:)
 

Mike Krailo

Well-known member
Local time
Today, 05:39
Joined
Mar 28, 2020
Messages
1,030
I'm surprised no one mentioned that DESC is a reserved word.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:39
Joined
May 21, 2018
Messages
8,463
I'm surprised no one mentioned that DESC is a reserved word.
Huh? It is used in an order by clause in a sql string. How do you use it?
 

Mike Krailo

Well-known member
Local time
Today, 05:39
Joined
Mar 28, 2020
Messages
1,030
Earlier in the thread he had a control named desc.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:39
Joined
May 21, 2018
Messages
8,463
Oh I see the field Description is "Desc". Yes bad choice.
Not as bad as this farmer I worked with one time on another forum. They had a table for Fields holding seeding and fertilizing data and a field for Rows in the fields. Another when was a furnitrure builder with tblTables for their tables.
 

Lucky33

Registered User.
Local time
Today, 02:39
Joined
Sep 3, 2011
Messages
57
Wow Mike. this reserved word missed me although I learned many years ago to avoid any reserved word. Thanks for the feed. I changed the name and now all codes are working fine, even my original one. Funny though how Access behaves sometimes. Some codes did not work but one worked, and all used Desc.
Pbaldy and MajP mentioned in earlier posts, things about the use of the wildcard. The final code of my original one that worked when i changed the name is the following, and that may change your mind about how one can use the wildcard with "Like":

Dim doShare As Double
Dim stShare As String

stShare = Me.IDesc

doShare = DLookup("[QueStocksDaily]![TotValue] ", "QueStocksDaily", _
" [QueStocksDaily]![DDate] =" & "#" & DMax(" [QueStocksDaily]![DDate] ", "QueStocksDaily") & "#" & "AND " & "'" & stShare & "' Like '*' & [Symbol] & '*'")


Again thanks to all who participated and shared their knowledge and I hope that others will benefit from this (y) :)
 

Users who are viewing this thread

Top Bottom