Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 29th, 2006, 02:50 PM
Authorized User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chacquard
Default Creating table with SQL to transfer to a CSV

hello,

I use a huge query to add records to a table (previously emptied) that I export as a CSV. This CSV is now too big. It has information on events. My boss wants me to create a csv for each event name.

So, if I have:

circus1 july 1
circus1 july 2
circus1 july 3
circus2 august 1
circus2 august 2
...

I now need to create circus1.csv and circus2.csv

How can I do it with Access ?

I have tried:

strSQL = "SELECT DISTINCT EVENT.EventName INTO " & [EventName] &" "& _
"FROM EVENT;"

but it doesn't work... :(

have any suggestions ?????

Thank you!!

Reply With Quote
  #2 (permalink)  
Old June 30th, 2006, 07:25 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You will have to run a process.

I would suggest creating a query on the EventName column, and selecting Distinct records, so your query output looks like this:

Circus1
Circus2
etc.

Then run a process that loops through each event in this query. From the process, call your current giant query where EventName = the currnet event name in your process. Alternatively, you can call all the event names from the EventName query into an array, and then loop through the array.

Then base your csv file on the name of the current event name.

SO it can be done quite easily. How much code help do you need? I should have time to help you get this working today.

mmcdonal
Reply With Quote
  #3 (permalink)  
Old June 30th, 2006, 07:31 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Code outline:

Create Connection
Create Recordset on EventName query
MoveFirst
Do Until rs.EOF
  sEvent = rs.Event
  sLink = "[EventName] = & "'" & sEvent & "'"
  sCSVFileName = sEvent & ".csv"
  DoCmd.OpenQuery "qryGiantQuery", , sLink
  DoCmd. ' create text file using sCSVFileName and overwrite any existing copies
  rs.MoveNext
Loop

HTH

mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get table records into Txt or CSV format kapi.goel SQL Language 0 April 10th, 2006 01:47 AM
create CSV flat file from mysql table pb MySQL 1 September 21st, 2005 10:51 AM
csv file into access table with vba Perseus Access VBA 2 September 14th, 2005 02:57 PM
Sql a .csv file langer123 Classic ASP Basics 2 April 18th, 2005 08:55 AM
Transfer SQL Database FROM One SQL PC To Another Israr SQL Server 2000 3 February 2nd, 2005 01:33 AM



All times are GMT -4. The time now is 02:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.