[AccessD] Dlookup syntax

Mackin, Christopher CMackin at Quiznos.com
Tue Jul 20 15:55:43 CDT 2004


Personally I find SQL strings a lot easier to read than any of the Lookup functions.

I use this and pass it a SQL string, returns the first value in the first field of the SQL statement.  It will return a Null when nothing is returned.....

Public Function CLookup(strSQL As String) As Variant
Dim rst As ADODB.Recordset

Set rst = New ADODB.Recordset
rst.Open strSQL, CurrentProject.Connection, adOpenStatic

If rst.EOF Then
  CLookup = Null
Else
  rst.MoveFirst
  CLookup = rst(0)
End If

rst.Close
Set rst = Nothing

End Function




-Chris Mackin


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller
Sent: Tuesday, July 20, 2004 2:32 PM
To: AccessD
Subject: [AccessD] Dlookup syntax


I can't remember how to format this! Bloddy L. The second thing to go is
memory. I forget what the first is.

Dim s as string
Dim x as Integer
Dim d as Date

d = Date()
X = Dlookup("myColumn", "myTable", "myDateColumn=#" & d & "#")

Doesn't seem to work. What should I be doing instead?

TIA,
Arthur



-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list