By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

Export parameter query to xml

P: 2
Hello, I'm having a problem trying to export output to an xml format.

I have a query that uses a form field as the query criteria. I want the query to execute without the prompt for the criteria.

This is the sql of the query:
Expand|Select|Wrap|Line Numbers
  1. SELECT FldRptsQueryPt1.*, FldRptsQueryPt1.rmsDetails.rmsNumber
  2. FROM FldRptsQueryPt1 LEFT JOIN OffensesQuery ON FldRptsQueryPt1.rmsDetails.rmsNumber = OffensesQuery.Offenses_rmsNumber
  3. WHERE (((FldRptsQueryPt1.rmsDetails.rmsNumber)=[Forms]![rmsDetails]![rmsNumber]));
The code I'm using to run the query is under a button on the rmsDetails form:
Expand|Select|Wrap|Line Numbers
  1. Application.ExportXML _
  2.     ObjectType:=acExportQuery, _
  3.     DataSource:="FldRptsQuery", _
  4.     DataTarget:="C:\FldRptsQuery.xml"

From the query window the query works when the form rmsDetails is open.

When I use the button on the form I get the prompt to supply the rmsNumber and then the data is exported. I would like to get rid of the prompt for the rmsNnumber.

I'm new to access so I don't know if I'm using the right approach for this situation.

Thanks you.
Feb 1 '08 #1
Share this Question
Share on Google+
5 Replies


P: 2
Hello, I'm having a problem trying to export output to an xml format.

I have a query that uses a form field as the query criteria. I want the query to execute without the prompt for the criteria.

This is the sql of the query:
SELECT FldRptsQueryPt1.*, FldRptsQueryPt1.rmsDetails.rmsNumber
FROM FldRptsQueryPt1 LEFT JOIN OffensesQuery ON FldRptsQueryPt1.rmsDetails.rmsNumber = OffensesQuery.Offenses_rmsNumber
WHERE (((FldRptsQueryPt1.rmsDetails.rmsNumber)=[Forms]![rmsDetails]![rmsNumber]));

The code I'm using to run the query is under a button on the rmsDetails form:
Application.ExportXML _
ObjectType:=acExportQuery, _
DataSource:="FldRptsQuery", _
DataTarget:="C:\FldRptsQuery.xml"


From the query window the query works when the form rmsDetails is open.

When I use the button on the form I get the prompt to supply the rmsNumber and then the data is exported. I would like to get rid of the prompt for the rmsNnumber.

I'm new to access so I don't know if I'm using the right approach for this situation.

Thanks you.
I found a solution. I'm posting here in case some one else may run into the same situation.

I removed the criteria from the query and used the filter criteria option on the exportxml method. My new export statement is:

Application.ExportXML _
ObjectType:=acExportQuery, _
DataSource:="FldRptsQuery", _
DataTarget:="C:\FldRptsQuery.xml", _
WhereCondition:="FldRptsQueryPt1.rmsDetails.rmsNum ber = '" & Forms!rmsDetails![rmsNumber] & "'"


My app now exports to an xml format without requesting input form the user.

Notice the "WhereCondition:=", in a lot the samples I ran across I saw "FilterCriteria" which does not work for me with Access 2003. My app does not deal with thousands of records so the filter option works for me. If you have to read lots of records this may not work for you.

Again I'm new to Access but the above method does work.
Feb 1 '08 #2

P: 2
Hi,

I have the exact function you used for exporting a query using a parameter however I am getting an error of "Run - time error '31532'
Microsoft Access was unable to export the data".

Do you have any idea why is this happening?
Jun 11 '14 #3

twinnyfo
Expert Mod 2.5K+
P: 3,054
flyishfish15,

Do you have the same version of MS Access as ladylexus? This could be an initial starting point for your issue.
Jun 11 '14 #4

P: 2
Hi twinnyfo my version of Access is MS Access 2013..Does this have any compatibility issue with MS Office 2013?
Jun 12 '14 #5

twinnyfo
Expert Mod 2.5K+
P: 3,054
flyingfish,

Your version of Acces (2013) should be fully compatible with MS Office 2013. However, if you are using code from a previous verison of Access it "could" affect your exports. I have only run into problems during exports like this--but it is rare.

At the same time, I have had lines of code work for years, and then all of a sudden, they will generate an error. Access is also not very informative when an error is generated. I wish I had better advice, but the OP did did find resolution.

Now, if we could only solve your issue....
Jun 12 '14 #6

Post your reply

Sign in to post your reply or Sign up for a free account.