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: 12
Default Overwrite a record instead of add

I have the following code that adds a record to an Access database:

Sub ADOFromExcelToAccess()
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=S:\MalLab\MAL_DB.mdb;"
Set rs = New ADODB.Recordset
rs.Open "CurrentPMT", cn, adOpenKeyset, adLockOptimistic, adCmdTable
With rs
.AddNew
.Fields("CurrentPMTScore") = Sheet1.Range("F1").Value
.Update
End With
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub

Can someone tell me how to overwrite the existing record instead of adding a
new one.

Thanks in advance,

MikeS
 
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
Open new record with selected fields from previous record Design by Sue Excel Discussion (Misc queries) 1 June 12th 09 02:24 PM
Prevent PivotTable Overwrite Warning and Disallow Overwrite jonahviakeyboard Excel Programming 0 November 27th 07 05:08 PM
Record macro doesn't record shape properties Tosco[_2_] Excel Programming 3 May 30th 07 02:28 AM
Record Macro - Record custom user actions Sal[_4_] Excel Programming 1 December 23rd 04 03:18 PM
Need help autopopulating next new record with previous record data Harry S[_3_] Excel Programming 2 October 1st 03 10:59 PM


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