View Single Post
  #2  
Old July 22nd, 2004, 09:00 AM
Albert D. Kallal
external usenet poster
 
Posts: n/a
Default DLOOKUP in an external Database gives TYPE Mismatch-Error

DLookup always looks in the current database, so you can't use it. You can
simply just create a sql statement, and use that:

xxFreeze = DLookup("P", DB("ALLDEF Attachments"),
"[Original Name] = '" & DB.TableDefs(i).Name & "'")


You can use:

dim rstLookup as dao.recordset
dim strLookupSql as string

strLookUpSql = "select P from [ALLDEF attachments] where [Original Name] =
'" & DB.TableDefs(i).Name & "'"
set rstLookup = DB.OpenReocrdSet(strLookUpSql)
if rstLookUp.RecordCount 0 then
xxFreeze = rstLookUp!P
else
xxFreeze = Null
end if
rstLookUp.Close
set rstLookup = nothing

You could also move the code to a function, and call it "mydlookup" or
somting like that....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada

http://www.attcanada.net/~kallal.msn