DLookup Criteria Syntax

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
 
Good to know you have a working solution:)
 
I'm surprised no one mentioned that DESC is a reserved word.
 
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?
 
Earlier in the thread he had a control named desc.
 
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.
 
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

Back
Top Bottom