The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills. This article applies only to a Microsoft Access database (.mdb). SYMPTOMSWhen you run a query based on a linked 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 recordset. CAUSEWhen 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:
Microsoft SQL Server then converts the value 12:35:00 to the following:
When you run a query in which the Criteria row for the Time field contains a literal value such as #12:35:00 PM# against this linked table, the SQL Server ODBC driver sends the following command to the SQL Server:
RESOLUTIONUse either of the following methods to resolve this problem. Method 1Create a parameter query in Microsoft Access. You can use the query-by-form technique and specify a control on a form as a parameter; you can also define the parameter in the query itself and specify its data type as Date/Time. For example:
Method 2Create the following expression in the query to extract the time portion of the field:Expr1: CVDate(Format([<Name of Time Field>],"hh:mm:ss AM/PM"))You can then enter the literal time value enclosed in number signs (#) on the Criteria row of this expression. STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. MORE INFORMATIONSteps to Reproduce Problem
REFERENCESFor more information about specifying the data type of query parameters, click Microsoft Access Help on the
Help menu, type specify the data type of a parameter in a parameter query in the Office Assistant or
the Answer Wizard, and then click Search to view the topic. Additional query words: linking attaching prb attach attached
Keywords : kbinterop kbdta QrySqlvw QryParm |
Last Reviewed: September 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |