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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup error 3464

Status
Not open for further replies.

AKMonkeyboy

IS-IT--Management
Feb 4, 2002
141
US
Need to lookup a Max value in a table and then use that to return another value from the same table. Have the code but am getting error 3464 (data type mismatch) when I execute the code.

Both fields I'm using to lookup are Long Integers so I'm perplexed why I keep getting the error.

I've tried with the single quote around MaxID and without.

Aaarrrrgggg!!

Any thoughts?

Here's what I have so far:

Code:
Dim MaxID As Integer

    MaxID = DMax("ID", "tblFileIndexEntriesIndexed")
    DocID = DLookup("FileName", "tblFileIndexEntriesIndexed", "[ID]=" & "'" & MaxID & "'")

MsgBox DocID

Give a man a fish, and you feed him for a day.
Teach a man to fish, and you feed
him for life.
Send a man to Tek-Tips and the poor sap can find out how to fish on his own, and learn more by doing it.
 
DMax takes 3 arguments: DMAX(database,field,criteria)

As far as I know, DLookup is not a function. Did you mean "VLookup"?

_________________
Bob Rashkin
 
You may try this:
Dim MaxID As Long
Dim DocID As Variant
MaxID = DMax("ID", "tblFileIndexEntriesIndexed")
DocID = DLookup("FileName", "tblFileIndexEntriesIndexed", "ID=" & MaxID)
MsgBox DocID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry it's been so long for me to post. I checked through my code and found an error - I was defining a string as an integer.

Imagine that, error codes that mean something!

Thanks all!

Give a man a fish, and you feed him for a day.
Teach a man to fish, and you feed
him for life.
Send a man to Tek-Tips and the poor sap can find out how to fish on his own, and learn more by doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top