Access.2007.VBA.Bibl..

(John Hannent) #1
chk = appAccess.CreateReportControl(ReportName:=rpt.Name, _
ControlType:=Microsoft.Office.Interop.Access.AcControlType.acCheckBox, _
Section:=Microsoft.Office.Interop.Access.AcSection.acDetail, _
Left:=0, Top:=4000, Width:=2500, Height:=400)

ErrorHandlerExit:
Exit Sub

ErrorHandler:
AddInErr(Err)
Resume ErrorHandlerExit

End Sub

Public Sub AddInErr(ByVal errX As ErrObject)

Displays a message box with error information.

Dim strMsg As String

strMsg = _
“An error occurred in the Extras add-in” _
& Microsoft.VisualBasic.Constants.vbCrLf _
& “Error #:” & errX.Number _
& Microsoft.VisualBasic.Constants.vbCrLf _
& “Description: “ & errX.Description
MsgBox(strMsg, MsgBoxStyle.Critical, “Error!”)

End Sub

The syntax for named constants is much more verbose in Visual Studio 2005 than in
Access VBA or VB 6: Instead of (for example) acControlType, you need the full enum
reference, Microsoft.Office.Interop.Access.acControlType.

If you turn on the Error List pane (View➪Error List), you will see a number of warnings
about implicit conversion of a variable from Access control to a specific Access control type (see
Figure 16.23).

In general, you can clear up conversion warnings by using a conversion function in the code, but
Visual Studio 2005 doesn’t have any conversion functions for Access controls, so you just have to
live with the warnings (the code will run fine).

NOTENOTE


Customizing the Access Ribbon with a Visual Studio 2005 Shared Add-in 16

Free download pdf