Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2005, 11:47 AM
Authorized User
 
Join Date: Jul 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default csv file into access table with vba


Hi,
could you help me please.

I have csv file:

#text1.1=#text2.1 !text3.1
#text1.2=#text2.2 !text3.2
...

I need fill this csv to access table with vba:
table:
----------------------------------------------------
| ID(automatic) | all row | text1.x | text2.x | text3.x |
----------------------------------------------------
Could you help me with vba, please (beginner)

 
Old September 14th, 2005, 12:52 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure what you have here. Please post some sample lines from the file if the data is not sensitive.

It looks like on each line you have three columns, each column ending with .1, .2, .3, and each column delimited by #, =, or !.

What you need to do is read this file one line at a time, then split the line into an array using a delimiting character, or ".", and then open your local table and do something like:

rs.AddNew
rs("All Row") = ?
rs("text1.x") = st1stVariable
rs("text2.x") = st2ndVariable
rs("text3.x") = st3rdVariable
rs.Update

Looking forward to more info.

HTH

mmcdonal
 
Old September 14th, 2005, 02:57 PM
Authorized User
 
Join Date: Jul 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

csv for examle:
#a_string1=#a_string2 !a_string3 ...first row of csv(record of table)
#a_string1=#a_string2 !a_string3 ...second rowof csv(record of table)
...

I have in access this table:
my_table(
id automatic_number,
all_row text,
string1 text,
string2 text,
string3 text,
)

my_table.all = all row in csv
my_table.string1 = string between first "#" and first "="
my_table.string2 = string between second "#" and first " !"
my_table.string3 = string between first " !" and end of row(\n)

I'd like fill data from csv into my_table.









Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming fields in access table using VBA imaley Access VBA 13 August 13th, 2009 02:22 PM
vba file access rema Excel VBA 0 August 28th, 2008 05:03 AM
Save a file in CSV format thru Excel VBA macro roli2712 Excel VBA 1 July 11th, 2007 03:05 AM
Text File-Newbie VBA Access mbeirn Access VBA 1 October 6th, 2005 07:18 AM
create CSV flat file from mysql table pb MySQL 1 September 21st, 2005 10:51 AM





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