Access.2007.VBA.Bibl..

(John Hannent) #1
End If
Resume ErrorHandlerExit

End Function

Public Function CreateCTTable()
‘Called from LNCRenameFormControls and
‘LNCRenameReportControls function
‘in this module

Dim strCTTable As String

strCTTable = “zLNCtblControlType”

Delete the old table, if there is one.


Set pdbs = CurrentDb
strCTTable = “zLNCtblControlType”
On Error Resume Next
pdbs.TableDefs.Delete strCTTable

On Error GoTo ErrorHandler

Generate the table of control types to use in renaming controls. If there is a “table not found” error,
exit function.


pstrSQL = “CREATE TABLE “ & strCTTable & _
“(ControlType LONG, ControlTypeName TEXT (50));”
DoCmd.RunSQL pstrSQL

Append data to the table of control types.


Set pdbs = CurrentDb
Set prst = pdbs.OpenRecordset(strCTTable, dbOpenTable)
With prst
.AddNew
!ControlType = 100
!ControlTypeName = “Label”
.Update
.AddNew
!ControlType = 101
!ControlTypeName = “Rectangle”
.Update
.AddNew
!ControlType = 102
!ControlTypeName = “Line”
.Update
.AddNew

Creating COM Add-ins with Visual Basic 6 13

Free download pdf