ELookup To Few Parm's, DLookup OK

bignose2

Registered User.
Local time
Today, 05:25
Joined
May 2, 2010
Messages
251
Hi,
Trying use ELookup within a function, using multiple times and easier to pass values and alos do some test on the data. However not really seen this done (Perhaps a bad idea) so struggling to see how the values should be referenced quotes, single quotes etc.

DLookup works as below (But want more speed as lots used on form)
I get too few parameters, I guess something in the where is not correctly held in " or 's btu not sure when passing a value.

The SQLdate this is something I picked up as have the usual problems with the US & UK dd/mm/yyyy & mm/dd/yyyy swapping thing, as this fixes it, so not really declared as date & left as is.


Public Function EPLIsBooked(EPLReturn As String, BookedDate As String, EPLDate As String, EPLEmail As String)

If IsNull(EPLDate) Then Exit Function

To Few Parameters
EPLIsBooked = ELookup(EPLReturn, "Dogs", BookedDate & " = " & SQLDate(EPLDate) & " AND Email = " & EPLEmail)


Works OK
EPLIsBooked = DLookup(EPLReturn, "[Dogs]", BookedDate & " = " & SQLDate(EPLDate) & " AND Email = " & EPLEmail)



End Function
 
Well to be honest neither should work...

To Few Parameters
Code:
EPLIsBooked = ELookup(EPLReturn, "Dogs", BookedDate & " = " & SQLDate(EPLDate) & " AND Email = " & EPLEmail)
Fixed
Code:
EPLIsBooked = ELookup(EPLReturn, "Dogs", "BookedDate = #" & SQLDate(EPLDate) & "# AND Email = """ & EPLEmail & """")


Works OK
Code:
EPLIsBooked = DLookup(EPLReturn, "[Dogs]", BookedDate & " = " & SQLDate(EPLDate) & " AND Email = " & EPLEmail)
Fixed
Code:
EPLIsBooked = DLookup(EPLReturn, "[Dogs]", "BookedDate = #" & SQLDate(EPLDate) & "# AND Email = """ & EPLEmail & """")

Note: The # around the date may already be done in SQLDate function

If you are doing multiple DLookups on a single table, your best recourse is to use SQL to limit I/O
 

Users who are viewing this thread

Back
Top Bottom