Import data using code

B

Ben

All,

I have a two tables, user and test. In the test table, I
have a form that has a command button. With a click of the
command button, the data from the user table will be
added/inserted into the test table. I think another user
asked a similar question, but I extend my and that user's
question further with more detail. My code is:

Dim Rd As DAO.Database
Dim testapp As DAO.Recordset
Dim addapp As DAO.Recordset

//The user.mdb file location in c: drive
Set Rd = OpenDatabase("C:\user.mdb")

// open the user table in the user.mdb
Set testapp = Rd.OpenRecordset("Select * FROM user")


//begin retreiving data from user table and insert the
info to the testuser table in test.mdb,which the test.mdb
is also located in c:\

If Not testapp.EOF Then
do while not(testapp.EOF)
Rd.Execute ("INSERT INTO testuser(firstname) VALUES ('"&
testapp("firstname") & "')")
testapp.movenext
Loop
End If

The problem is that the insert didn't work. The firstname
did not get insert into the testuser table in test.mdb.
The access program keep on running and I need to terminate
the program using the task manager. What am I doing wrong
with the code. Any suggestions?

Thanks for the help,

mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top