Hi guys,
I have a query, would like to export the query with 10 different filters and to 10 different locations in XML format.
Suggestion of Vba code?
thanks.
br Olof
Hi guys,
I have a query, would like to export the query with 10 different filters and to 10 different locations in XML format.
Suggestion of Vba code?
thanks.
br Olof
Could use QueryDefs to modify the query filter criteria.
Then maybe open the query and run:
Docmd.RunCommand acCmdExportXML
or
Create an Export definition and run:
Docmd.RunSavedImportExport
Repeat the code for each of the 10 criteria. Could probably loop the procedure like:
For i = 1 to 10
Select Case i
Case 1
"filter string 1"
...
Case 10
"filter string 10"
End Select
'code to set query filter
'code to export the query
Next i
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
You are asking us to guess some sample data. Show us data, show us what input you have and what you want to output.
We only know what you tell us. And so far, you've shown nothing.
Thank you June, Though I have tride without success.
Therefor an example attached.
I would like to export the table to two xml-files to my desktop with two filters for column (Department)
Filter 1 "HR"
Filter 2 "Finance"
Thanks br Bertrand
What have you tried? That database does not have any code. Provide the exact code you attempted.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I think i need code from scratch
You have made no attempt to adapt the code outlined in earlier post?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Hi June, my VBA knowledge is limited to the higheste extent.
I have solved it with:
Sub ExportToXmlFile()
Application.ExportXML ObjectType:=acExportTable, DataSource:="Table1", DataTarget:="C:\Table1.xml", WhereCondition:="Department ='Finance' "
Application.ExportXML ObjectType:=acExportTable, DataSource:="Table1", DataTarget:="C:\Table2.xml", WhereCondition:="Department =HR"
Application.ExportXML ObjectType:=acExportTable, DataSource:="Table1", DataTarget:="C:\Table3.xml", WhereCondition:="Department ='HR'AND Name='Harry'OR Name='Michael ' "
etc...
etc...
End Sub
Does it make sence?
I have never used the ExportXML method so I checked your syntax. Congratulations, it looks good but for couple little errors.
Need apostrophes around HR in the second line.
Need parentheses around the the Name criteria. Don't lose spaces that separate text - in front of AND and in front of OR
WhereCondition:="Department='HR' AND (Name='Harry' OR Name='Michael')"
Seems do not need to use QueryDefs after all if the WhereCondition argument works.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thank you! Thread Solved!