473,385 Members | 1,218 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,385 software developers and data experts.

Exporting to a text file

I have a query called qrylabels that is based on a table tblbospen. I want
to run the query from the Switchboard and also export the results from the
query to a comma separated text file called labels.txt. I know how to do
these procedures individually but I want it to be a seamless operation on
clicking a choice in the switchboard where the only intervention by the user
would be to ask them where to save the file. Can this be done using either a
macro or VBA? I'm a novice at VBA so please go gentle with me!
TIA
Tony Williams
Nov 13 '05 #1
2 1452
This is how I would do it:

Paste the following code into a new module:

Function QandX(QryN As String, QryN2 as string fileName As String)
On Error GoTo erh
DoCmd.SetWarnings False
DoCmd.OpenQuery QryN
DoCmd.SetWarnings True
DoCmd.OutputTo acOutputQuery, QryN2, "Text Files (*.txt)", fileName,
False
xit:
DoCmd.SetWarnings True
Exit Function
erh:
MsgBox Error$
Resume xit
End Function
Then make a macro where you choose the following command:
runcode
then in the little entry box you write

QandX(x,y, y)
where x is the name of the query you are running, and
y the name ofthe query that you are outputting, and
z the filename that you want it to be.

Lastly, you include the macro in your switchboard.

Any further questions, please ask
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004
Nov 13 '05 #2
Thanks I'll try that and come back to you if I get stuck if I may
Tony
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:SR********************@news.xtra.co.nz...
This is how I would do it:

Paste the following code into a new module:

Function QandX(QryN As String, QryN2 as string fileName As String)
On Error GoTo erh
DoCmd.SetWarnings False
DoCmd.OpenQuery QryN
DoCmd.SetWarnings True
DoCmd.OutputTo acOutputQuery, QryN2, "Text Files (*.txt)", fileName,
False
xit:
DoCmd.SetWarnings True
Exit Function
erh:
MsgBox Error$
Resume xit
End Function
Then make a macro where you choose the following command:
runcode
then in the little entry box you write

QandX(x,y, y)
where x is the name of the query you are running, and
y the name ofthe query that you are outputting, and
z the filename that you want it to be.

Lastly, you include the macro in your switchboard.

Any further questions, please ask
---
Please immediately let us know (by phone or return email) if (a) this email contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004
---
Please immediately let us know (by phone or return email) if (a) this email contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jayjay | last post by:
Is it possible to export a report to word and have it include the graphics that are in the report? I'd like to take some of our reports and export them to word so we can email those to the...
3
by: Fran Zablocki | last post by:
I have a process that exports an Access table to a comma-delimited text file. One of the fields that is exported shows the date it was exported, using the Date() function. In the Access table, the...
2
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
1
by: nunYa | last post by:
I am trying to use the DoCmd.TransferText method to export an access table to a Tab Delimited Text File. I have put the code behind the onclick event of a button and keep getting the error...
4
by: Hitesh | last post by:
Hi, I have three datagrid control on my aspx page and one export to excel button, i want to export all the 3 datagrids contents in one excel file. how can i achive that? -- Thanks Hitesh
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
16
by: pmatzek | last post by:
I am attempting to automate a process involving importing a .txt file into an existing table, changing a date in each record, then exporting the table, again as a .txt file. One field contains a...
1
by: Marty Klunk | last post by:
I have an Access97 data base where we are exporting records out to a text file that is then sent to a customer via EDI transmission. The problem I am having is that during the export process access...
2
by: JimmyKoolPantz | last post by:
We purchased som software for encoding a barcode. We want to automate the process of converting a number to a readable barcode. However, I am having a few issues. The file that the barcode...
1
by: ndedhia1 | last post by:
hello, I am creating a comma delimited text file in php and need to export the results to an excel file. I am creating the text file thru querying a mySql database. Right now, we have the .txt...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.