I wish to add recorsets to access table from MS Word VBa Code

G

Guest

Dear all, here is my faulty code
Sub feed_table()
Dim conn As ADODB.Connection ' Connect to the database
Dim rst As ADODB.Recordset ' target recordset
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Administrateur\Mes documents\registered.MDB;"


rst.ActiveConnection = conn
rst.Source = "T_Etat_Civil" ' the table I would like to update
' I define the cursor type
rst.CursorType = adOpenDynamic
rst.Open ' I open the table

rst.AddNew "Nom", "Cadieu "
rst.AddNew "Prénom 1", "Toto Hervé"
rst.AddNew "Date de naissance", "24 / 7 / 1969"
rst.Close
conn.Close ' we close the connection

End Sub

unfortunately I get error message telling me error 3251 current recordset
does not support updating this may be a limitation of the provider or the
selected locked type..

who can help me to solve my issue ? (Id est write me the missing line(s) to
get it working) Thanks much in advance
best regards
 
B

Brian Stoll via AccessMonster.com

Instead of:
rst.ActiveConnection = conn
rst.Source = "T_Etat_Civil" ' the table I would like to update
' I define the cursor type
rst.CursorType = adOpenDynamic
rst.Open ' I open the table


Try:
Set rst = conn.OpenRecordset("T_Etat_Civil", dbOpenDynaset, dbSeeChanges)

You might have to:
Dim conn As DAO.Database
Dim rst As DAO.Recordset

'Then set the dbs to the file...
Set conn = "C:\Documents and
Settings\Administrateur\Mes documents\registered.MDB"

I'm not sure how it works with an external database...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top