Access.2007.VBA.Bibl..

(John Hannent) #1
Copy various objects to the calling database, if they don’t already exist. These objects are needed to
support the add-in’s functionality:

Set dbsCalling = CurrentDb
strCallingDb = CurrentDb.Name
Set tdfsCalling = dbsCalling.TableDefs
strTable = “zstblAccessDataTypes”
Set tdfCalling = tdfsCalling(strTable)
DoCmd.SetWarnings False
If tdfCalling Is Nothing Then
Debug.Print strTable & “ not found; about to copy it”
DoCmd.CopyObject destinationdatabase:=strCallingDb, _
newname:=strTable, _
sourceobjectType:=acTable, _
sourceobjectname:=strTable
End If

Set ctr = dbsCalling.Containers(“Reports”)
strReport = “zsrptTableAndFieldNames”
Set doc = ctr.Documents(strReport)
If doc Is Nothing Then
DoCmd.CopyObject destinationdatabase:=strCallingDb, _
newname:=strReport, _
sourceobjectType:=acReport, _
sourceobjectname:=strReport
End If

strReport = “zsrptQueryAndFieldNames”
Set doc = ctr.Documents(strReport)
If doc Is Nothing Then
DoCmd.CopyObject destinationdatabase:=strCallingDb, _
newname:=strReport, _
sourceobjectType:=acReport, _
sourceobjectname:=strReport
End If

ErrorHandlerExit:
Exit Function

ErrorHandler:
MsgBox “Error No: “ & err.Number _
& “; Description: “ & err.Description
Resume ErrorHandlerExit

End Function

Part III Adding More Functionality to Office

Free download pdf