Error msg when adding reocrds
From: Gman (Gman_at_discussions.microsoft.com)
Date: 02/05/05
- Next message: Karen Hart: "Re: Runtime Installation problems on XP Service Pack 2 Machines"
- Previous message: John Vinson: "Re: Payments Schedule"
- Next in thread: John Vinson: "Re: Error msg when adding reocrds"
- Reply: John Vinson: "Re: Error msg when adding reocrds"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 5 Feb 2005 15:45:01 -0800
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
- Next message: Karen Hart: "Re: Runtime Installation problems on XP Service Pack 2 Machines"
- Previous message: John Vinson: "Re: Payments Schedule"
- Next in thread: John Vinson: "Re: Error msg when adding reocrds"
- Reply: John Vinson: "Re: Error msg when adding reocrds"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|