Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a record on values in two fields 1

Status
Not open for further replies.

tamus121

Technical User
Mar 19, 2007
38
GB
Hi
I am lookoing up a record in a table with
s = DLookup("[ShareNumbersTo]", "CertificateDetails", "[ShareNumbersTo]=(Select Max([ShareNumbersTo]) from [CertificateDetails])")

and this works ok to a point but I want the largest share number for only the selected type of share. So If I have ShareType = "O", I want the largest share number for shares of [Tpye] O. I can't get this work when I try to inculde "[Type] = ShareType" in the above statement. Any sugestions would be great.

 

Perhaps (not tested)
Code:
Select Max([ShareNumbersTo]) from [CertificateDetails] [b][COLOR=red]WHERE ShareType = 'O'[/color][/b])


Randy
 
[Type] is the name of the field in CertificateDetails

So I have tried

Code:
ShareType = "O"

or other depending on option selected by user

Code:
s = DLookup("[ShareNumbersTo]", "CertificateDetails", "[ShareNumbersTo]=(Select Max([ShareNumbersTo]) from [CertificateDetails] WHERE [Type] = 'ShareType')")

It gives me the largest share number without WHERE but this may not be the correct one but "s" gives me nothing when i have the WHERE clause
 
Code:
s = DLookup("ShareNumbersTo", "CertificateDetails", "ShareNumbersTo=(Select Max(ShareNumbersTo) from CertificateDetails WHERE Type='" & ShareType & "')")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top