need help importing text file into tables

L

Leo

Hi, i have trouble importing data from a text file to the fields in a table.

I got the reading to work using VB through a command button attached to a
form on access, so each time i press the command button, it only reads
specific parts and ignores the unneeded parts and also assigns it to
variables (each variable will have around 10 to 50 records that way, and are
supposed to go into the same table, note i also have 9 variables/fields). Ok
i was thinking to attach the variables and to connect them to fields on my
table (each variable = 1 field, note i dont need a primary key), but havent
been able to figure it out yet
:(
 
J

John Vinson

Hi, i have trouble importing data from a text file to the fields in a table.

I got the reading to work using VB through a command button attached to a
form on access, so each time i press the command button, it only reads
specific parts and ignores the unneeded parts and also assigns it to
variables (each variable will have around 10 to 50 records that way, and are
supposed to go into the same table, note i also have 9 variables/fields). Ok
i was thinking to attach the variables and to connect them to fields on my
table (each variable = 1 field, note i dont need a primary key), but havent
been able to figure it out yet
:(

I'm sorry, this isn't making any sense to me. Each *variable* will
have 10 to 50 *records*?

To insert data into a table you would open a Recordset based on the
table, and assign values (what I'd call variables) to the fields. For
example:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("YourTableName", dbOpenDynaset)
<read your file>
<loop through the records to be added>
rs.AddNew ' add a new record
rs!ThisField = ThisVariable
rs!ThatField = ThatVariable
<etc>
rs.Update 'write the new record to the table
<close the loop>


John W. Vinson[MVP]
 
S

SirPoonga

I don't understand either. The first question that pops in my head is
can you use thet ext inport wizard?

If not you will need to explain in a little more detail and a little
more clearer on what you are trying to do.
 
Top