Hi I'm new to VBA and I'm just trying to create a connection object to the database and also a recordset object in order to add new records to the database. I am directly connected to the database and everytime I compile the following piece of code which is inside a Module it gives me a compile error for Dim dbCurrent As Database and dbMichael As Database. How do I get rid of it. Here is the code:
Option Compare Database
Option Explicit
Function AddPlayer()
Dim dbCurrent As Database
Dim rstPlayers As Recordset
Dim rstCards As Recordset
Dim dbMichael As Database
Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
'This will create a table-type recordset.
Set rstPlayers = dbMichael.OpenRecordset("Players", "databases\Michael.mdb", DB_OPEN_DYNASET)
'These will create a dynaset-type recordset.
Set rstCards = dbMichael.OpenRecordset("Cards", "databases\Michael.mdb", DB_OPEN_DYNASET)
rstPlayers.Move 4
End Function
Hopefully somebody can help- thanks in advance![]()
![]()




Reply With Quote