PDA

View Full Version : [SOLVED:] Add Record To Access Table - Getting Error



unified
08-24-2006, 07:47 PM
:banghead: I'm using Excel 2000 and Access 2000, and I am trying to add a new record to a table. I'm using the code below, and I keep getting an error stating : "Current recordset does not support updating". I realize that there must be a better way of writing this, but my searches on the internet only gained ASP examples that were not even close to what I am trying to do. I will eventually use Excel to update the table. Can anyone point me into the right direction, as well as any links to tutorials or books?



Dim Conn, RS
Dim QueryStr As String
Set Conn = CreateObject("ADODB.Connection")
Set RS = CreateObject("ADODB.RecordSet")
QueryStr = "SELECT * FROM NURSES"
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\whitestone\whitestone.mdb"
RS.Open QueryStr, Conn
'MsgBox RS!FirstName <-- used to test connection
'MsgBox RS!LastName <-- used to test connection
RS.AddNew
RS!FirstName = "Octavius"
RS.Update
Conn.Close
Set Conn = Nothing

stanl
08-25-2006, 04:47 AM
try changing RS.Open QueryStr, Conn to RS.Open QueryStr, Conn, 1,3,1
Stan

unified
08-25-2006, 02:46 PM
Thanks, that worked! :)

But, what do those parameters mean? Or, better, where can I find information on their use?

stanl
08-27-2006, 05:24 AM
http://www.w3schools.com/ado/met_rs_open.asp

Stan

unified
08-27-2006, 07:46 AM
Thanks. :)