473,465 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Excel Macro export data to specific Access Record

9 New Member
Hello,
I am trying to create an excel macro, that when clicked... a specific cell will match a record in my database, and update certain fields in this record.

The Excel file will have a cell that is the same as a 'Tracking Number' (the primary key) of my Access Table. The output from excel would access this record and update the field.

I currently have a macro to create new records in the table, but I am not sure if there is a way to update certain records.

Thanks,
Adam
Dec 10 '07 #1
3 4187
redbenn
9 New Member
here is the code i have currently to add a new record:
Expand|Select|Wrap|Line Numbers
  1. Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long
  2.     ' connect to the Access database
  3.     Set cn = New ADODB.Connection
  4.     cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
  5.         "Data Source=c:\db1.mdb;"
  6.     ' open a recordset
  7.     Set rs = New ADODB.Recordset
  8.     rs.Open "ProjectInbound", cn, adOpenKeyset, adLockOptimistic, adCmdTable
  9.     ' all records in a table
  10.  With rs
  11.             .AddNew ' create a new record
  12.             ' add values to each field in the record
  13.  
  14.             .Fields("Output") = Range("C10").Value
  15.  
  16.             ' add more fields if necessary...
  17.             .Update ' stores the new record
  18.  End With
  19.  
  20.  With Application
  21.         .ScreenUpdating = False
  22.         .DisplayAlerts = False
  23.     End With
  24.  
Dec 10 '07 #2
redbenn
9 New Member
I found this clause in some other code, which may be what I am looking for, but I cannot figure out the context
Expand|Select|Wrap|Line Numbers
  1. .Open "select * from c_test where c_testid = '" & labelID.Caption & "'"
Dec 10 '07 #3
redbenn
9 New Member
I also found this bit of code
Expand|Select|Wrap|Line Numbers
  1. rs.Find("Tracking Number=" & Range("A1").Value)
  2.  
but I get this error:
"arguments are of the wrong type..."
Dec 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
3
by: John | last post by:
Is there a way to code the button that's available in the query window--microsoft excel icon that exports to excel. I know transferspreadsheet will do this---but I want the query, which is in a...
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: michb | last post by:
I need to export data from access to an excel database to calculate times and wages for the week but the code that I entered doesn't seem to like either me or the database! I need it to go to one...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
10
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
6
by: jcf378 | last post by:
hello-- i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.