ADODB and DAO recordset issues

Scott Heslop

Registered User.
Local time
Today, 22:59
Joined
Aug 29, 2012
Messages
17
Hi,

Ive just recently changed my database from a *.MDB to a *.ACCDB. Once i done this my ''New ADODB Recordet" no longer exists. and i ashume i need to use a DAO recordset. I need to add a new record and make the employeeId to + 1. Here is my code i had with the ADODB recordset. Can someone provide me with the code for doing the same job but from a DAO recordet? It usually gets stuck when i reach the code in bold. Any suggestions?

:banghead:

Private Sub AddNewRecordAndDisplayIt()
Dim vMaxRecNo As Variant
Dim MySQL As String
Dim CurrRec As New ADODB.Recordset

Me.AllowAdditions = True

'Find current max rec no.

vMaxRecNo = DMax("nEmployeeID", "EmployeeDetails")
If IsNull(vMaxRecNo) Then
nCurrRecID = 1
Else
nCurrRecID = vMaxRecNo + 1
End If
With CurrRec
.Open "EmployeeDetails", CurrentProject.Connection, adOpenStatic, adLockPessimistic
.AddNew
!nEmployeeID = nCurrRecID 'Primary Key
.Update
.Close
End With
Set CurrRec = Nothing
Me.AllowAdditions = False
'Display the new record.
MySQL = "SELECT a.* From EmployeeDetails a where a.nEmployeeID =" & nCurrRecID
Me.RecordSource = MySQL
End Sub
 
Ive just recently changed my database from a *.MDB to a *.ACCDB. Once i done this my ''New ADODB Recordet" no longer exists.

Check your bindings in the VBA editor: Tools \ References.

The standard ADO objects get activated by enabling Microsoft ActiveX Data Objects 2.8 Library (assuming your system has MDAC 2.8 installed, which most do these days)

Make sure to review what bindings existed in the former .MDB file as well.
 

Users who are viewing this thread

Back
Top Bottom