473,472 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Access Data to CSV file

xxoulmate
77 New Member
how can i extract data from access table into csv file format.,
i want it to save through query.,

i have example of sql query saving in xls format., but i want the query result to save in csv format.
eg. xls format
- "Select Fields into TempData in 'sample.xls' 'Excel 5.0;' from From Table"
May 19 '09 #1
10 7455
ADezii
8,834 Recognized Expert Expert
@xxoulmate
I can show you a Custom Routine that I created which will write specific Query Field Values to a CSV (Comma Seperated Value) File but I'll wait and see if anyone has a better idea. I'm probably mistaken, but I do not think that there is an easy way to accomplish this through the Access Interface, but there is programmatically.
May 19 '09 #2
xxoulmate
77 New Member
how bout., instead of saving it in csv file save it in text file through query
May 19 '09 #3
harshakusam
36 New Member
This method will help you...

Expand|Select|Wrap|Line Numbers
  1. The TransferText method has the following syntax and options:
  2.  
  3. DoCmd.TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)
  4.  
  5.  

This will work...

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2. strSQL = "Your select statement"
  3. DoCmd.TransferText ExportDelim, "strSQL", "path.csv"
  4.  
May 19 '09 #4
xxoulmate
77 New Member
how can i add this to vb 6 program
ex.
i will use the access database
location = "c:\db1.mdb"
query = "select * from table1"


how can i use docmd in vb
May 19 '09 #5
NeoPa
32,556 Recognized Expert Moderator MVP
There is an option to save an object (Table or QueryDef will work - NOT SQL string) as a CSV file within Access (VBA). If you need to know how to access this via VB, then I suggest the VB forum is where you need help (although I suspect it may be as simple as having an Access application variable in your code and using AccVar.DoCmd ...). Would you like me to move this over for you?
May 25 '09 #6
ADezii
8,834 Recognized Expert Expert
@xxoulmate
It took me a little while, but I did come up with what may be a workable solution, the 'Base Code' of which I'll post for you. Basically, if the Filename contains 'Exec ' it is converted and Renamed to 'Exec_', the Import occurs without any problems, and the User is notified of this process. If the Filename does not contain 'Exec ', it is Imported normally. It is up to you as to whether or not it is a viable Option:
Expand|Select|Wrap|Line Numbers
  1. Public Function fImportCSVFile(strFileName As String)
  2. Dim strNewName As String
  3.  
  4. If InStr(strFileName, "Exec ") > 0 Then     'does "Exec " appear in the File Name
  5.   strNewName = Replace(strFileName, "Exec ", "Exec_")
  6.     Name strFileName As strNewName      'Rename the File replqacing Exec  with Exec_
  7.       DoCmd.TransferText acImportDelim, , "CSV Table", strNewName, False
  8.       MsgBox strFileName & " has been Renamed to " & strNewName & " in order to avoid " & _
  9.                            "Import Errors", vbExclamation, "Change in File name"
  10. Else
  11.   DoCmd.TransferText acImportDelim, , "CSV Table", strFileName, False
  12. End If
  13. End Function
To successfully Import a File with 'Exec ' contained within its Name:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print fImportCSVFile("C:\Dezii\Exec Test.csv")
May 26 '09 #7
NeoPa
32,556 Recognized Expert Moderator MVP
Wasn't the "Exec in filename" issue from another thread?
May 26 '09 #8
ADezii
8,834 Recognized Expert Expert
@NeoPa
I do believe you're corect, NeoPa. Just add it to my ever growing 'OOPs List'. Actually, I think I may have Double-Posted, sorry.
May 26 '09 #9
NeoPa
32,556 Recognized Expert Moderator MVP
I think the giggle was worth it ADezii ;)

Besides, you more than make up for any senior moment lapses.
May 26 '09 #10
HAL4u
1 New Member
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferText acExportDelim, "KlasExportspecificatie", "Resultaten", "C:\Users\HAL\Desktop\" & klKlassen.Value & " " & sKeuze & ".csv"
  2.  
  3. "KlasExportspecificatie"      is the exportspecification I created with the export wizard, containing the settings for CSV files
  4. "Resultaten"                  is the table from which the data is exporting
  5. "C:\Users\HAL\Desktop\" & klKlassen.Value & ".csv"
  6.                               is the file path to where the file is exported
  7. klKlassen.Value               is the value from a list-box which contains a part of the filename
The trick is to make a exportspecification in the Export Wizard.
Right-click the exported table. Choose EXPORT, TXT-file.
All checkboxes not checked.
Use on the next page the ADVANCED-button to modify and save the exportspecification.

That does the trick, HAL
Jan 18 '10 #11

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

Similar topics

3
by: *no spam* | last post by:
I want to move my Access 2K database into MSDE. The Access Upsizing Wizard crashes (a known bug wi A2K), so I'm using the following suggested method: Access --> New --> Project (Existing...
10
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network...
3
by: Marc Nadeau | last post by:
Hi, I have a new project that consist of transfering a JD Edwards Database to an MS Access database. I am just starting to learn how those 2 databases works. What is the general idea behind...
8
by: John Baker | last post by:
Hi: I am URGENTLY in need of some book or web site OR tool that will help me integrate a relatively simple access application into a web page or pages. This is a time recording system (by...
7
by: Ruben Baumann | last post by:
Just wondered if anyone has had occasion to use, or does use, FileMaker, or Raining Data's Omnis, or Alpha5's software, and how they compare with Access? Ruben
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
70
by: lgbjr | last post by:
Hello All, I've been developing a VB.NET app that requires the use of a DB. Up to now, I've been using Access. It's a bit slow, but everything works. I'm at a point now where I need to decide if...
6
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.