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 SubErrorHandler:
AddInErr(Err)
Resume ErrorHandlerExitEnd SubPublic Sub AddInErr(ByVal errX As ErrObject)Displays a message box with error information.Dim strMsg As StringstrMsg = _
“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 SubThe 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