O
OldEnough
Just learning to use ADO. The code example below illustrates what I'd like to
do using ADO, though I'm not sure quite how to do it.
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblMyTable", dbOpenDynaset)
rs.AddNew
rs!MyField1= Me.Field1
rs!MyField2 = Me.Field2
rs.Update
rs.Close
Set rs = Nothing
As close as I can come the ADO would look something like this (Help Please)
Dim AccessConnect as String
AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};†& _
“Dbq=" & BackEndPath & "; DefaultDir=" & FrontEndPath & ";" & _
"Uid=Admin;Pwd=;"
Dim oRS As New ADODB.Recordset
Dim cnn As New ADODB.Connection
cnn.ConnectionString = AccessConnect
cnn.Open
Set oRS = New Recordset (Not sure if this is correct)
With oRS
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.AddNew
oRS!MyField1= Me.Field1
oRS!MyField2 = Me.Field2
.Update
.Close
End With
cnn.Close
cnn.ConnectionString = ""
Corrections to this non-working code would be appreciated.
do using ADO, though I'm not sure quite how to do it.
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblMyTable", dbOpenDynaset)
rs.AddNew
rs!MyField1= Me.Field1
rs!MyField2 = Me.Field2
rs.Update
rs.Close
Set rs = Nothing
As close as I can come the ADO would look something like this (Help Please)
Dim AccessConnect as String
AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};†& _
“Dbq=" & BackEndPath & "; DefaultDir=" & FrontEndPath & ";" & _
"Uid=Admin;Pwd=;"
Dim oRS As New ADODB.Recordset
Dim cnn As New ADODB.Connection
cnn.ConnectionString = AccessConnect
cnn.Open
Set oRS = New Recordset (Not sure if this is correct)
With oRS
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.AddNew
oRS!MyField1= Me.Field1
oRS!MyField2 = Me.Field2
.Update
.Close
End With
cnn.Close
cnn.ConnectionString = ""
Corrections to this non-working code would be appreciated.