ACC: Query w/Time Criteria Returns No Records from MS SQL ServerID: Q173097
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you run a query based on a linked (attached) Microsoft SQL Server
table that contains a Date/Time field, and the criteria for the Date/Time
field contains a literal time value, Microsoft Access returns an empty
result set.
When a linked SQL Server table contains a field with a data type of
Date/Time, and you insert a time value such as 12:35:00 PM into the table,
the following calls are made by the SQL Server ODBC driver:
SQLPrepare :
INSERT INTO "dbo"."tblTimeTest" VALUES (?)
SQLBindParam:
12:35:00
1899-12-30 12:35:00.00
SQLExecDirect:
SELECT "dbo"."tblTimeTest"."TimeTest" FROM "dbo"."tblTimeTest" WHERE _
("TimeField" = {t '12:35:00'})
Use either of the following methods to resolve this problem.
Field: TimeField
Criteria: [Enter Time]
Expr1: CVDate(Format([<Name of Time Field>],"hh:nn:ss AM/PM"))
Microsoft has confirmed this to be a problem in Microsoft Access.
create table tblTimeTest (ID int, TimeField datetime)
go
create unique index tblTimeTest_ndx on tblTimeTest (ID)
ID TimeField
-- ----------
1 12:35:00
Query: qryTest
-------------------------
Type: Select Query
Field: ID
Table: dbo_tblTimeTest
Field: TimeField
Table: dbo_tblTimeTest
Criteria: #12:35:00#
For more information about specifying the data type of query parameters, search the Help Index for "data types, parameter queries."
Additional query words: linking attaching
Keywords : kbinterop QrySqlvw QryParm
Version : WINDOWS:2.0,7.0,97
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 17, 1999