LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Moving data from Excel to Access

Hi all,

Hopefully someone can help. I am trying to use some code to move some text
entered into a spreadsheet into an Access database, however when I run the
code I get the error "Compile error: User-defined type not defined" with the
"cn As ADODB.Connection" portion of the code highlighted. Am I missing
something very obvious?

My code is:-

Sub AddInfoToTAMDB()
Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=K:\TAM Message.mdb;"

Set rs = New ADODB.Recordset
rs.Open "Customers", cn, adOpenKeyset, adLockOptimistic, adCmdTable

With rs
.AddNew
.Fields("DateTime") = txtTAMDateTime.Value
.Fields("CallHandler") = txtTAMCH.Value
.Fields("IFAName") = txtIFAName.Value
.Fields("IFAFirm") = txtIFAFirm.Value
.Fields("PostCodeorAgencyNumber") = txtPostCode.Value
.Fields("PhoneNumber") = txtTelNo.Value
.Fields("AccountManager") = txtAccMan.Value
.Fields("Message") = txtMessage.Value
.Update
End With
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub

All help greatly appreciated!!

Thanks, Will
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving excel workbook with access query to another folder Nick Excel Discussion (Misc queries) 0 January 6th 10 03:00 PM
Moving Data between sheets in the same workbook and moving data between Workbooks. Alison Brown Excel Worksheet Functions 0 February 10th 09 01:03 AM
Moving an Excel pivot table to access JSF Excel Worksheet Functions 2 September 18th 06 10:27 PM
Moving linked Excel/Access files to another machine CaroleN Links and Linking in Excel 1 August 11th 05 01:58 PM
moving data between excel and access shin Excel Programming 1 January 24th 04 05:15 AM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"