As Database Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring database error vbulletin developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Error Establishing A Database Connection
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; database error wordpress it only takes a minute: Sign up Access VBA: Error when declaring the type of a Database object: User defined type is not defined up vote 3 down vote favorite In Access 2010 VBA, if I run this sub: sub
Database Error Forum
test Dim db Dim rst Set db = CurrentDb() Set rst = db.OpenRecordset("select * from mytable") Debug.Print "db: " & TypeName(db) Debug.Print "rst: " & TypeName(rst) end sub then it shows (in the "Inmediate" panel): db: Database rst: Recordset2 so it works, and all libraries are installed correctly (ADO for example). Ok, now I want to declare explicitly the variable types, by using the types that were shown ("Database" and "Recordset2"), so I modify the sub in this way: database error website sub test Dim db as Database ' explicitly Dim rst as Recordset2 ' explicitly Set db = CurrentDb() Set rst = db.OpenRecordset("select * from mytable") Debug.Print "db: " & TypeName(db) Debug.Print "rst: " & TypeName(rst) end sub and when I run it, I get the following error at line "Dim db as Database": Compilation error: User defined type is not defined So I understand that type "Database" is not defined (!). Why? Note: I have also tried: Dim db as ADO.Database ' explicitly Dim rst as ADO.Recordset2 ' explicitly and: Dim db as ADODB.Database ' explicitly Dim rst as ADODB.Recordset2 ' explicitly and: Dim db as DAO.Database ' explicitly Dim rst as DAO.Recordset2 ' explicitly and got same error with all of them. How is it possible? Why does it work if I don't declare the type? Edit: I have just discovered that Access also offers an ADODB.Connection object for the current database, by calling to "CurrentProject.Connection". So I can explicitly declare: sub test Dim db As ADODB.Connection Set db = CurrentProject.Connection ' Access gives an ADODB object too! Dim rst As ADODB.Recordset Set rst = New ADODB.Recordset rst.Open "select * from mytable", db Debug.Print "db: " & TypeName(db) Debug.Print "rst: " & TypeName(rst) end sub that shows: db: Connection rst: Recordset So I will use it, since ADO is more modern than DAO. database ms-access compiler-errors ms-access-2010 declaration share|improve this question edited Feb 24 '14 a
help? Post your question and get tips & solutions from a community of 418,429 IT Pros & Developers. It's quick & easy. "Dim db as Database" generates an error P: n/a Bart Lateur For some reason, "Database"
Database Error Gametrailers
isn't recognised by Access as a built-in/predefined type, in Access' own VBA. Whenever I try
Database Error Stream Not Found
to compile a line like Dim db as Database I get the complaint that that user defined type ("database") isn't defined. This happens both database error unable to connect to the database in Access 97 (on Win98) and in Access 2000 (on XP). I seem to recall this used to work on Access 2. For the rest, Access works normally. CurrentDB does seem to work, but I need to be able http://stackoverflow.com/questions/21989581/access-vba-error-when-declaring-the-type-of-a-database-object-user-defined-typ to pass a database as a parameter, as I'm trying to relink tables to a moved/renamed .mdb file by code, as is done in this sample code: