473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

unable to export to xml using a form field in where clause

I am trying to export a query to xml but when I hard code the filter on the vba it export, but when I want to use form it fails. the user will not have access to the code so its better if he can put parameter in the form and the code execute. This is my code, I use Access 2013

Expand|Select|Wrap|Line Numbers
  1. Application.ExportXML _
  2.  ObjectType:=acExportQuery, _
  3.  DataSource:="claim4", _
  4.  DataTarget:="D:\OBELSOFT DEVELOPMENT\Xml tests\New folder\tblexportINV10.XML", _
  5. WhereCondition:="claim4.transactionno > '" & Forms!claimxml2![txtInv] & "'"
please help
Feb 21 '19 #1

✓ answered by twinnyfo

Obakeng1168,

Welcome to Bytes!

Using Form values in strings can sometime produce unexpected results. This is why it is always better to declare a variable that uses that Form value and incorporate it into a string separately. Try this:

Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2.  
  3. Strfilter = "claim4.transactionno > '" & Forms!claimxml2![txtInv] & "'"
  4.  
  5. Application.ExportXML _
  6.     ObjectType:=acExportQuery, _
  7.     DataSource:="claim4", _
  8.     DataTarget:="D:\OBELSOFT DEVELOPMENT\Xml tests\New folder\tblexportINV10.XML", _
  9.     WhereCondition:=strFilter
Also, it looks like you are using a numerical value for transactionno? If this is the case, line 3 above would be:

Expand|Select|Wrap|Line Numbers
  1. Strfilter = "claim4.transactionno > ' & Forms!claimxml2![txtInv]
(No need for single quotes with numerical values.)

Hope this hepps!

8 2118
twinnyfo
3,653 Expert Mod 2GB
Obakeng1168,

Welcome to Bytes!

Using Form values in strings can sometime produce unexpected results. This is why it is always better to declare a variable that uses that Form value and incorporate it into a string separately. Try this:

Expand|Select|Wrap|Line Numbers
  1. Dim strFilter As String
  2.  
  3. Strfilter = "claim4.transactionno > '" & Forms!claimxml2![txtInv] & "'"
  4.  
  5. Application.ExportXML _
  6.     ObjectType:=acExportQuery, _
  7.     DataSource:="claim4", _
  8.     DataTarget:="D:\OBELSOFT DEVELOPMENT\Xml tests\New folder\tblexportINV10.XML", _
  9.     WhereCondition:=strFilter
Also, it looks like you are using a numerical value for transactionno? If this is the case, line 3 above would be:

Expand|Select|Wrap|Line Numbers
  1. Strfilter = "claim4.transactionno > ' & Forms!claimxml2![txtInv]
(No need for single quotes with numerical values.)

Hope this hepps!
Feb 21 '19 #2
Thanks a lot, it worked for me perfectly. Now how can I make the exported xml file to leave out "dataroot" line and replace it with my own line like "BatchClaim" both from the top and bottom of the xml document.
Mar 1 '19 #3
Sorry one other thing how do I make my date to display only date not date and time 2018-12-28T00:00:00 in the xml file
Mar 1 '19 #4
twinnyfo
3,653 Expert Mod 2GB
Obekeng1168:
Now how can I make the exported xml file to leave out "dataroot" line and replace it with my own line like "BatchClaim" both from the top and bottom of the xml document.
I have no idea what you are talking about.

Obekeng1168:
how do I make my date to display only date not date and time 2018-12-28T00:00:00
Change the format in your query using the Format() function.
Mar 1 '19 #5
<?xml version="1.0" encoding="UTF-8"?>

-<dataroot generated="2019-03-01T15:07:10" xmlns:od="urn:schemas-microsoft-com:officedata">


-<claimBatch>

<Transactionno>973</Transactionno>


-<Batchheader>

<BatchNo>7</BatchNo>

<BatchDate>2019-03-01T00:00:00</BatchDate>

<schemecode>Pula</schemecode>

<Source>58010</Source>

<Transactionno>973</Transactionno>

</Batchheader>

That the dataroot line in xml file
Mar 1 '19 #6
twinnyfo
3,653 Expert Mod 2GB
Apparently that line is generated by the system itself. It is not part of your exported query, so apparently there isn't anything you can do about it on the front end. You might be able to work with it after the fact. Is there a reason you need to remove it?

Concerning the date, if you can isolate that string, you can remove everything after the "T". This gives you just the date. But again, that is after the fact. Obviously you are using this data after it is exported to xml?
Mar 1 '19 #7
Hello team

I am using 5 queries to generate xml file, I managed to use Format([invoicedate],"dd\/mm\/yyyy") to change the date from including time, but when I put it in other queries which also have date which is including time it refuses to export.

Can anyone assist me
Mar 5 '19 #8
twinnyfo
3,653 Expert Mod 2GB
I will recommend you begin a new thread and in that new thread provide more detailed information than what you have provided here. To say that you are using 5 queries and putting one query with the others does not help us trouble shoot. Please post the queries in this new thread, allong with sample data that you are using and a detailed description of intended results and actual results.

Thanks.
Mar 5 '19 #9

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

Similar topics

7
by: diroddi | last post by:
I am having a problem using a dynamic where clause. I have a feeling that I am overlooking something very simple, although I can't seem to figure it out. The error i'm getting is: You have an...
2
by: Largo SQL Tools | last post by:
Can anyone tell me if it's possible to use a Case statement in a Where clause, and if so, the proper syntax? J.R. Largo SQL Tools The Finest Collection of SQL Tools Available...
4
by: Barry Edmund Wright | last post by:
I would really appreciate your assistance. I am using Access 2000 to create a form that Lists Names and Addresses based on a number of selection criteria one of which is a combo box cboPCZip. All...
2
by: kuhni | last post by:
Hi everybody, I have a problem with my SQL-Statement: SELECT * FROM WHERE (((Year > 2003) And (Month <= 6)) Or (Year = 2003)) The WHERE-clause doesn't work properly. As result I receive...
3
by: gupta.harika | last post by:
Hi everyone, I am a developer working on php with oracle as backend. I am facing a problem related with the CLOB data. The problem is as follows My application uses a table which contains Clob...
2
by: MCOOP | last post by:
Is there a way to have a declare variable (@where) be used as the WHERE clause in a stored procedure? The reason I ask is that I'm trying to use one sql statement for several possible WHERE...
8
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
3
by: ineuw | last post by:
I am trying to change the shadowed (sunken) form fields to display flat borders. I tried using various CSS parameters, without any result. Any help is greatly appreciated.
0
NeoPa
by: NeoPa | last post by:
Intention : To prepare a WHERE clause for multiple field selection, but to ignore any fields where the selection criteria are not set. ONLY WORKS WITH TEXT FIELD SELECTIONS. Scenario : You have...
9
by: Brad Pears | last post by:
I have the following code that references a "textbox" on a form. I want to pass the value of this textbox to a stored procedure as a parameter. This code is located on a different form obviously. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.