Re: Add new record in ADO
Try this
Code:
dim db as database
dim rs as recordset
'Opens the database Mydb in folder My Documents
set db=opendatabase("C:\My Documents\Mydb.mdb")
'Opens table Mytable from Mydb
set rs=db.openrecordset("Mytable")
'Adds a new record
rs.Addnew
'Copy text from txtMyName to field Section
rs!Section=txtMyName.text
'Update the field
rs.Update
'Close the table
rs.Close
'Close the database
db.Close
'This for clear memory
set db=nothing
Re: Add new record in ADO
Thank you for your reply. This is essentially what I had already done. It turns out that the entire problem was the way I was opening the database. I was using
rsRecordset.Open SQLStatement, connection, adOpenStatic, adLockBatchOptimistic
which caused my problem. The solution was to open the dB with this:
rsRecordset.Open SQLStatement, connection, adOpenStatic, adLockOptimistic
Now all is well. Thanks for the reply though.