473,425 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Export MS Access table via OBDC using VB

I'm trying to export a reference table from MS Access to a table via
ODBC. Is there a way I can use a DAO.Recordset and use the
value(field) to populate my ODBC table?

Dim rs as DAO.Recordset
Dim conn as New ADODB.Connection
Dim strsql as String

Set rs = CurrentDb.OpenRecordset("select field1, field2, field3,
field4, field5.....from daotable").Openrecordset
Move.First

strsql = "insert into odbctable rs.value(field1, field2, field3,
field4, field5.....)

conn.ConnectionString = "dsn=Database ; uid=UID; pwd=password"
conn.ConnectionTimeout = 0
conn.CommandTimeout = 0
conn.Open

Do
conn.Execute (strsql)
rs.MoveNext
Loop Unit rs.EOF

conn.close

Dec 17 '05 #1
2 5362
It goes something like

Dim rs as DAO.Recordset
Dim conn as New ADODB.Connection
Dim strsql as String

Set rs = CurrentDb.OpenRecordset("select field1, field2, field3,
field4, field5.....from daotable")

conn.ConnectionString = "dsn=Database ; uid=UID; pwd=password"
conn.ConnectionTimeout = 0
conn.CommandTimeout = 0
conn.Open

with rs
do until .eof
strsql = "insert into odbctable ( F1, F2, F4, F4, F5) " _
& "VALUES (" & .Fields("field1") & ", " .Fields("field2") _
& ", " & .Fields("field3") & ", " & .Fields("field4" _
& ", " & .Fields("field5") & ")"

conn.execute strsql
.movenext
loop
end with
conn.close

' etc...

You'll need t insert single quotes (') in their as well if the fields are
strings.

--
Terry Kreft

"rjgst3" <rj****@rmu.edu> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I'm trying to export a reference table from MS Access to a table via
ODBC. Is there a way I can use a DAO.Recordset and use the
value(field) to populate my ODBC table?

Dim rs as DAO.Recordset
Dim conn as New ADODB.Connection
Dim strsql as String

Set rs = CurrentDb.OpenRecordset("select field1, field2, field3,
field4, field5.....from daotable").Openrecordset
Move.First

strsql = "insert into odbctable rs.value(field1, field2, field3,
field4, field5.....)

conn.ConnectionString = "dsn=Database ; uid=UID; pwd=password"
conn.ConnectionTimeout = 0
conn.CommandTimeout = 0
conn.Open

Do
conn.Execute (strsql)
rs.MoveNext
Loop Unit rs.EOF

conn.close

Dec 17 '05 #2
Bri
rjgst3 wrote:
I'm trying to export a reference table from MS Access to a table via
ODBC. Is there a way I can use a DAO.Recordset and use the
value(field) to populate my ODBC table?

Dim rs as DAO.Recordset
Dim conn as New ADODB.Connection
Dim strsql as String

Set rs = CurrentDb.OpenRecordset("select field1, field2, field3,
field4, field5.....from daotable").Openrecordset
Move.First

strsql = "insert into odbctable rs.value(field1, field2, field3,
field4, field5.....)

conn.ConnectionString = "dsn=Database ; uid=UID; pwd=password"
conn.ConnectionTimeout = 0
conn.CommandTimeout = 0
conn.Open

Do
conn.Execute (strsql)
rs.MoveNext
Loop Unit rs.EOF

conn.close


AIRCODE based on your sample code
=======

Dim rs as DAO.Recordset
Dim conn as New ADODB.Connection
Dim strsql as String

Set rs = CurrentDb.OpenRecordset("select field1, field2, field3,
field4, field5.....from daotable").Openrecordset
Move.First

conn.ConnectionString = "dsn=Database ; uid=UID; pwd=password"
conn.ConnectionTimeout = 0
conn.CommandTimeout = 0
conn.Open

Do
INSERT INTO Member ( MemberID, [CCA-ID] )
SELECT Member.MemberID, Member.[CCA-ID]
FROM Member;

strsql = "insert into odbctable (field1, field2, field3)" & _
"Values (" & rs("field1") & ", " & rs("field2") & _
", " & rs("field3") & ") "

conn.Execute (strsql)
rs.MoveNext
Loop Unit rs.EOF

conn.close

END AIRCODE

--
Bri

Dec 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JJ | last post by:
Hi, usually, I'm not using MS servers, but I have a big problem with a Access table. I should create a web application for a Historical Dipartment. They have create a populated a Access...
4
by: JJ | last post by:
Hi, usually, I'm not using MS servers, but I have a big problem with a Access table. I should create a web application for a Historical Dipartment. They have created a populated a Access...
7
by: Keon | last post by:
Hoi, I'm using a database with alot of records in 1 table (more than 3000). If i want to export this table to excel i only get it till record 2385. Do someone know how i can solve this...
3
by: bwhite | last post by:
I have a temp table with one row of data that I need to export into Excel. I created the export to create the xls file as follows ... Dim FileName FileName = !! DoCmd.SetWarnings False...
1
by: Stella | last post by:
Help!!! Am extremely new to VBA. Want to set up code behind a button that will prompt the user for a table name(source of data) and file name(end result of export) and then export the data into a...
1
by: Harnish | last post by:
Hey All! This is Harnish. I am extremely new to both VBA and this forum! Could anyone please point me to some sample code (VB) to export a table in MS Access to MySQL. Essentially my...
5
by: bhodgins | last post by:
Hi, I am new on here, and had a newbie question that I am stumped with. I am not new to access, but am new to VB. I am trying to export BLOBs from a field called photo to external jpeg files. I...
1
by: vdama | last post by:
Hi, I am using MS-Access as back end table for VB application. In the access table there are four columns as sno,productioncount ,percentage and totalcount. Here in prodcution count filed we have...
0
by: JFKJr | last post by:
Hello everyone! I am trying to export Access table data into Excel file in such a way that the table field names should be in the first line of each column in excel file followed by field data, and...
9
by: mabrynda | last post by:
Good morning everybody, I have an ACCESS project, in which I was expotring some tables as TXT files to be used as input for some MATLAB code. Until now, these tables were "static" - means the number...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
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?

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.