I am working on this Access 2002 database. It uses linked servers to SQL Server 2008. I am having a problem where in load of the main form it does a DLookup and looks at a date.
EndDate = Nz(DLookup("End_Date", "Employee", "EmpID= " & EmpID & " AND End_Date IS NOT NULL AND End_Date < #" & Now & "#"), "")
Now this works fine in Access 2002, but in Access 2010 I get the:
Conversion failed when converting date and/or time from character string
Here’s the kicker though, it works in Access 2010 for one user: myself. No other users does it work for and also other installations with Windows 7 and the Access 2010 Runtime work fine. On the same machine the MDB works correctly also. If I replace the Pound signs with single quotes like in SQL Server it runs fine on the 2010 machine but no longer works on 2002 (duh).
It’s just been wracking my brain and normally I have been able to get it to work by uninstalling all of Office and then reinstalling and making sure the SP1 for the Access Runtime was installed last.
Instead of transforming the value of
Now()to a string in yourDLookup, just let the db engine determineNow()for itself.That approach does not depend on a conversion between Date/Time and string and back again, so will avoid the problem you reported.
If you want to examine how the original
DLookupgave different results, try something like this on the different machines:After running that code, go to the Immediate window (Crtl+g) and inspect the value of
strCriteria.