Access queries with a wildcard character do not export data to an XML document (823224)
The information in this article applies to:
- Microsoft Office Access 2003
This article applies only to a Microsoft Access database (.mdb).
Moderate: Requires basic macro, coding, and interoperability
skills.
SYMPTOMSWhen you export an Access query to an XML document, and the
query contains a Microsoft Jet wildcard character such as an asterisk (*) in
the criteria, the data is not exported to the XML document. Therefore, the
resultant XML document does not contain any data.
The query functions
correctly if you run the same query by using Access. CAUSEThis behavior occurs when you export to XML. XML uses
ActiveX Data Objects (ADO) to query the data from the database. When you use a
Jet-specific wildcard character in the Access query, the query returns no
records. This problem occurs because ADO recognizes only American National
Standards Institute (ANSI) 92 wildcard characters.WORKAROUNDTo work around this problem, use one of the following
methods:
- Method 1
You can rewrite the query to replace the Jet-specific
wildcard character with the ANSI 92 wildcard character. For example, the
original query may look similar to this with the * wildcard character:
SELECT Customers.CustomerID
FROM Customers
WHERE (((Customers.CustomerID) Like "A*")); You can rewrite the query as follows:
SELECT Customers.CustomerID
FROM Customers
WHERE (((Customers.CustomerID) Like "A%")); Note If the Access database is not configured for ANSI 92
compatibility, when you run the rewritten query from Access, no data is
returned. However, the exported XML document that is based on the rewritten
query returns the expected results. - Method 2
You can rewrite the query so that the criterion of the
query does not contain wildcard characters. For example, the original query may
look similar to this with the * wildcard character:
SELECT Customers.CustomerID
FROM Customers
WHERE (((Customers.CustomerID) Like "A*")); You can rewrite the query as follows:
SELECT Customers.CustomerID
FROM Customers
WHERE Left(CustomerID,1) = "A"; - Method 3
When you export data to an XML document, you can
specify whether to apply an existing filter on the object. Instead of
specifying a wildcard character in the criteria of the query, you can create a
filter with the filter string equivalent to the criteria that you want (such as
"A*") and then apply this filter during the Export XML process.
To do
this, follow these steps:
- Open the Northwind sample database.
- On the Insert menu, click
Query.
- In the New Query dialog box, select
Design View and then click OK.
- On the View menu, click SQL
View.
- In the Query window, paste the
following query:
SELECT Customers.CustomerID
FROM Customers;
Note You can see that the criterion of the query is removed.
Therefore, the query does not contain any wildcard characters. - On the File menu, click
Save.
- In the Query Name box of the
Save As dialog box, type
Query1.
- On the View menu, click
Datasheet View.
- On the Records menu, point to
Filter and then click Advanced
Filter/Sort....
- In the Field list, select
CustomerID.
- In the Criteria box under
CustomerID, paste the following code:
Like "A*" - On the Filter menu, click
Apply Filter/Sort....
- On the File menu, click
Save.
- On the File menu, click
Close.
- In the Database window, click
Queries.
- Right-click Query1 and then click
Export.
- In the Export Query 'Query1' To...
dialog box, select XML in the Save as type
list and then click Export.
- In the Export XML dialog box, click
More Options.
- In the Export XML dialog box, select
the Data tab. Under Records To Export, click
to select the Apply existing filter check box and then click
OK.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed at the beginning of this article.
REFERENCESFor more information about ANSI 92 syntax, type
about ansi sql query mode in the Office Assistant and then click Search.
Modification Type: | Minor | Last Reviewed: | 6/24/2004 |
---|
Keywords: | kbXML kbExport kbbug KB823224 kbAudDeveloper |
---|
|