Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExportXML WhereCondition does not work

Status
Not open for further replies.

0212

Technical User
Apr 2, 2003
115
US
Hello! I am having trouble exporting a specific record to XML. I would like to pass the Assignment No. from an open form to the report so that I filter and export only one record. I start with a Dialogue Box and enter an assignment no. I attached code to the dialogue OK Button that passes this information to a query which is the record source of the Form HSE MM POC and opens it. The query criteria for [Assignment No]request this information from the Dialogue Box. The specific record then is displayed in the Form HSE MM POC. On the Form HSE MM POC I have an XML Export Command Button. I have attached the below code.

Note that I have created a report that is identical to the form called Rpt HSE MM POC with the same record source as the form. However, the whereclause does not work. I get the query parameter window requesting the query criteria from the Dialogue Box. If I enter the assignment no, it will then export correctly. Again, I would like the assignment no to be passed to the report source query and only export one record.

Application.ExportXML _
ObjectType:=acExportReport, _
DataSource:="Rpt HSE MM POC", _
DataTarget:="Rpt HSE MM POC.xml", _
PresentationTarget:="Rpt HSE MM POC.xsl", _
WhereCondition:="Reports![Rpt HSE MM POC] _
[Assignment No]=" & "'" & Me![Assignment No] & "'"
I know this is long winded. Please let me know if you need additional information. Thanks for any help that you can give!!!
 
0212,
Punctuation (between the form name and the field name)?
[tt]WhereCondition:="Reports![Rpt HSE MM POC][red].[/red][Assignment No]=" & _
"'" & Me![Assignment No] & "'"[/tt]

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thank you, CautionMP!! Do you have any suggestions on any references on SQL/VBA Punctuation and Concantenation? Thanks!

Jim
 
I'm trying to do something similar to 0212 -- I have a command button on my form that opens a report and filters it by the data in my form's current record. I keep getting run time error 31532 - Access unable to export the data. My code follows:

DoCmd.OpenReport "MissionReport", acViewReport, , "MsnID = " & Me!MissionID
Application.ExportXML ObjectType:=acExportReport, DataSource:="MissionReport", DataTarget:="MissionXML.xml", WhereCondition:="Reports![MissionReport].[MsnID]=" & _
"'" & Me![MissionID] & "'"

My report opens and is filtered by the appropriate record, but the XML won't export with the wherecondition. If I remove the wherecondition, all of the data in the query used to produce the report is exported, even though the report is displayed as a filtered report. Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top