Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default VBA Excell/access prob

Here is the problem I am using a Rube Goldberg device to get two
programs to work with each other the first is a database which exports
records from its proprietary database format to excel. So I have taken
all of these excel files and consolidated them using code that I have
written now here is the problem I am trying to get the code to import
the serial # and the class name into the access database. But when I
do I get a 3421 data mismatch error. This is because the class field
is actually a lookup field with a primary key that is a number and a
description that is a memo I am trying. The lookup needs to be a text
input but it logs by class number

Sub DAOFromExcelToAccess()
' exports data from the active worksheet to a table in an Access
database
' this procedure must be edited before use
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C:\Documents and Settings\fiskb001\Desktop
\2009.mdb")
' open the database
Set rs = db.OpenRecordset("main table", dbOpenTable)
' get all records in a table
r = 3 ' the start row in the worksheet
Do While Len(Range("A" & r).Formula) < ""
' repeat until first empty cell in column A
With rs
.AddNew ' create a new recor
.Fields("Serial #") = Range("B" & r).Value
.Fields("class") = Range("C" & r).Value
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub


Reply
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
Tracking inventory in excell or access tracking_guru Excel Worksheet Functions 1 August 4th 08 10:22 PM
Importing data from excell to access. Tobes Excel Discussion (Misc queries) 2 November 14th 07 08:31 AM
Unable to access my Excell 2003 Mac05 Setting up and Configuration of Excel 1 August 3rd 05 07:05 PM
Importing data from Access into Excel: prob w/ cutting off fields Nicole L. Excel Worksheet Functions 1 February 7th 05 10:05 PM
Why can't we see or access MS Excell 2003 even though we have MS . SouthernBell Setting up and Configuration of Excel 2 December 1st 04 12:08 AM


All times are GMT +1. The time now is 09:11 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"