Hello all, I have a problem that goes something like this:
I have created a workbook wherein I have this module saved:
This module runs fine and the recordset is as it should be.
If I look in the references for this workbook, I have these references checked in this order:
Now, if I copy this code over to my Personal workbook and try to run the module I get the error message:
I'm basically trying to get this module to run just from my personal workbook because I don't want to have to keep opening the workbook where the module actually works in order to copy a recordset of 12k+ lines into an Excel workbook.
As soon as I navigate to my personal workbook, the DAO 3.6 Object Library disappears and it won't let me activate the reference. I get this error:
Has anyone had this problem before? Can you shed some light on how I can work around it?
Thanks all.
R
I have created a workbook wherein I have this module saved:
Code:
Sub DAOTest()
Dim db As Database
Dim rs As Recordset
Dim intColIndex As Integer
Dim mydb As String
Dim FieldName As String
Dim MyCriteria As String
Dim TableName As String
mydb = "\\Gmukht002s\Data\CommAcc\Pur Com Reports (BLMs)\Data\Pur_Com_Database.mdb"
Set TargetRange = Range("A1")
Set db = OpenDatabase(mydb)
Set rs = db.OpenRecordset("SELECT * FROM " & TableName)
For intColIndex = 0 To rs.Fields.Count - 1
TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name
Next
TargetRange.Offset(1, 0).CopyFromRecordset rs
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
This module runs fine and the recordset is as it should be.
If I look in the references for this workbook, I have these references checked in this order:
Visual Basic for Applications
Microsoft Excel 10.0 Object Library
OLE Automation
Microsoft Office 10 Object Library
Microsoft Forms 2.0 Object Library
Microsoft DAO 3.6 Object Library
Now, if I copy this code over to my Personal workbook and try to run the module I get the error message:
Compile Error:
User-defined type not defined
is highlighted."... db As Database"
I'm basically trying to get this module to run just from my personal workbook because I don't want to have to keep opening the workbook where the module actually works in order to copy a recordset of 12k+ lines into an Excel workbook.
As soon as I navigate to my personal workbook, the DAO 3.6 Object Library disappears and it won't let me activate the reference. I get this error:
Name conflicts with existing module, project, or object library
Has anyone had this problem before? Can you shed some light on how I can work around it?
Thanks all.
R