G
Gman
I am attempting to add records to a table using the code below. I get a type
mismtch error using DAO and an Object variable not assigned error using ADO.
eventually I will be taking data from a form and adding it to an added
records log table. I tookthe code directly from the reference books, But Im
stuck on the basics somewhere . Any Ideas? Thank you
DAO code
Sub AutoEnterStudents()
Dim CurDB As Database
Dim MyRecordSet As Recordset
Set CurDB = CurrentDb
Set MyRecordSet = CurDB.OpenRecordset("tblStudents")' This is where I get
the error
With MyRecordSet
.AddNew
!LName = "Scott"
.Update
End With
MyRecordSet.Close
End Sub
ADO Code
Sub AutoEdit2()
Dim CurConn As ADODB.Connection
Dim MyTable As ADODB.Recordset
Set CurConn = CurrentProject.Connection
' This is where I get the error
MyTable.CursorType = adOpenKeyset
MyTable.LockType = adLockOptimistic
MyTable.Open "tblStudents", CurConn, , , adCmdTable
With MyTable
.AddNew
!LName = "Scott"
.Update
End With
MyTable.Close
Set MyTable = Nothing
CurConn.Close
Set CurConn = Nothing
mismtch error using DAO and an Object variable not assigned error using ADO.
eventually I will be taking data from a form and adding it to an added
records log table. I tookthe code directly from the reference books, But Im
stuck on the basics somewhere . Any Ideas? Thank you
DAO code
Sub AutoEnterStudents()
Dim CurDB As Database
Dim MyRecordSet As Recordset
Set CurDB = CurrentDb
Set MyRecordSet = CurDB.OpenRecordset("tblStudents")' This is where I get
the error
With MyRecordSet
.AddNew
!LName = "Scott"
.Update
End With
MyRecordSet.Close
End Sub
ADO Code
Sub AutoEdit2()
Dim CurConn As ADODB.Connection
Dim MyTable As ADODB.Recordset
Set CurConn = CurrentProject.Connection
' This is where I get the error
MyTable.CursorType = adOpenKeyset
MyTable.LockType = adLockOptimistic
MyTable.Open "tblStudents", CurConn, , , adCmdTable
With MyTable
.AddNew
!LName = "Scott"
.Update
End With
MyTable.Close
Set MyTable = Nothing
CurConn.Close
Set CurConn = Nothing