Hi, JJ.
it complains because it now needs the reference Microsoft DAO 3.6 object
library. So I need to set the reference in DB2 from VBA in DB1.
Do you mean set the reference manually using the References dialog window
from the VBA code window (VB Editor), or set the reference via VBA code? If
it's manual, then please see the following Web page for a link to Tom
Wickerath's article, "ADO and DAO Library References in Access Databases":
http://www.Access.QBuilt.com/html/articles.html
If it's via code, then try: (watch out for word wrap, as the AddFromFile
function should be all one line)
Public Sub addLibRef()
On Error GoTo ErrHandler
Dim accApp As New Access.Application
accApp.OpenCurrentDatabase "C:\Work\DB2.mdb", True
accApp.References.AddFromFile "C:\Program Files\Common Files\Microsoft
Shared\DAO\dao360.dll"
accApp.RunCommand acCmdCompileAllModules
CleanUp:
accApp.Quit
Set accApp = Nothing
Exit Sub
ErrHandler:
MsgBox "Error in addLibRef( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
GoTo CleanUp
End Sub
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.