The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills. SYMPTOMSWhen 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. 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 P.M. 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:
For more information about the query-by-form technique, please see the
following article in the Microsoft Knowledge Base:
Q95931 ACC: How to use the Query-by-Form (QBF) Technique Method 2Create the following expression in the query to extract the time portion of the field: NOTE: If you are using Microsoft Access version 2.0, be sure to type the alias Expr1: along with the rest of the expression to avoid receiving a
syntax error message.
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 Behavior
REFERENCESFor 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 kbdta QrySqlvw QryParm |
Last Reviewed: August 30, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |