Dim db As Database
Dim rec As Recordset
Set db = OpenDatabase(App.Path & "\Database\UsersDB.mdb" _
, False, False, ";pwd=AdmiN")
Set rec = db.OpenRecordset("Users", dbOpenTable)
why before codes make error?
anyone can tell me?
You need to be a little more specific. What error are you getting? You might also want to take a look at the following site as it is a great resource for connection strings.
Set rec = db.OpenRecordset("Users", dbOpenTable)
from the test is the before syntax has error.
the error information is
realtime error '13'
can anyone know why.
I created a database and a table within it just like your example and the code worked fine.
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = OpenDatabase("C:\UsersDB.mdb" _
, False, False, ";pwd=AdmiN")
Set rec = db.OpenRecordset("Users", dbOpenTable)
Make sure you add a reference to Microsoft DAO X.X Object Library. Also make sure that your database exists and that the table that you are referencing exists as well.
i use
Dim db As DAO.Database
Dim rec As DAO.Recordset
instead of
Dim db As Database
Dim rec As Recordset
the code works well.
why?
what's the difference between DAo.database and database
?
horoscope, the following code will work for me as well. You just need to make sure you have a reference set for Microsoft DAO X.X Object Library.
Dim db As Database
Dim rec As Recordset
Set db = OpenDatabase("C:\UsersDB.mdb" _
, False, False, ";pwd=AdmiN")
Set rec = db.OpenRecordset("Users", dbOpenTable)
MsgBox rec.Fields(0).Value
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.