Hi:
When I add controls to a page of a form/multi form page, then sometimes it happens
that instead of one, there are two controls overlaying each other. i.e. 2 text boxes.
I wrote the following code to help me identify the names of controls on each page of
the multi page control.
sub printControls()
Dim p As Variant
Dim f As UserForm, i As Integer, ctl As Control, strAppPath As String
Const w As Integer = 25, strLine As String = "----------------------------------------------------"
p = Array("frmMain", _
"frmTransactions", _
"frmSuppliers", _
"frmCustomers", _
"frmAddTransactions", _
"frmStaff", _
"frmProducts", _
"frmPaymentMethods", _
"frmAddSupplier", _
"frmAddCustomers", _
"frmAddStaff", _
"frmAddProduct", _
"frmAddPaymentMethod", _
"frmStockManagement", _
"frmReporting", _
"frmChangePassword", _
"frmLoad", _
"frmLogin")
strAppPath = ThisWorkbook.Path & "\FormControls.txt"
Open strAppPath For Output As #1
For i = LBound(p) To UBound(p)
Print #1, p(i) & vbLf & Left(strLine, Len(p(i)))
Set f = frmCompanyDB.Access.Pages(i - 1)
For Each ctl In f.Controls
Print #1, vbTab & Right(Space$(w) & ctl.Name, w) & " Left: " & WorksheetFunction.Text(ctl.Left, "000") & " Top: " & WorksheetFunction.Text(ctl.Top, "000")
Next ctl
Print #1, vbLf
Next i
Close #1
end sub
This was working well and now I found some controls with default names (textbox1, textbox2, etc).
The question s: How can I identify these controls on my form(s) and remove them?
For example:
The following is a partial output from my controls list by multipage forms:
...
imgShareOfTransactionVolume Left: 138 Top: 061
imgShareOfSalesVolume Left: 303 Top: 061
MultiPage1 Left: 138 Top: 270
imgSalesRatio Left: 000 Top: 000
imgTotalRatio Left: 001 Top: 001
lblAllTransactions Left: 138 Top: 228
imgShareOfurchaseVolume Left: 467 Top: 061
lblTotalSalesAmount Left: 012 Top: 360
imgPurchaseRatio Left: 264 Top: 001
frmReporting
lblDownloadAllData Left: 018 Top: 018
Frame2 Left: 018 Top: 042
cmdCustomersReporting Left: 006 Top: 006
cmdSuppliersReporting Left: 092 Top: 006
cmdStaffReporting Left: 178 Top: 006
cmdTransactionsReporting Left: 264 Top: 006
lblDownloadWithQueries Left: 018 Top: 126
Frame3 Left: 018 Top: 138
lblSelectTable Left: 018 Top: 006
lbTableName Left: 012 Top: 024
lblSelectField Left: 108 Top: 006
lbFieldName Left: 108 Top: 024
cboWhere Left: 240 Top: 021
lblCriteria Left: 240 Top: 043
cboCriteria Left: 240 Top: 059
txtFrom Left: 286 Top: 096
txtTo Left: 240 Top: 096
txtSQL Left: 342 Top: 024
cmdRun Left: 342 Top: 090
Frame4 Left: 000 Top: 108
- Label21 Left: 006 Top: 006
- ListBox3 Left: 006 Top: 024
- Label22 Left: 168 Top: 006
- ListBox4 Left: 168 Top: 024
- Label23 Left: 300 Top: 006
- ComboBox1 Left: 300 Top: 022
- Label24 Left: 300 Top: 045
- ComboBox2 Left: 300 Top: 061
- TextBox4 Left: 300 Top: 084
- TextBox5 Left: 346 Top: 084
- TextBox6 Left: 414 Top: 024
- CommandButton1 Left: 414 Top: 084
- Label25 Left: 000 Top: 084
imgCancelReporting Left: 018 Top: 432
lvReporting Left: 018 Top: 288
imgExport Left: 468 Top: 090
chkAllFields Left: 210 Top: 006
lblWhere Left: 240 Top: 006
lblFrom Left: 240 Top: 081
Label29 Left: 288 Top: 081
lblSQLStatement Left: 342 Top: 006
frmChangePassword
txtPasswordCurrent Left: 150 Top: 084
txtPasswordNew Left: 150 Top: 138
txtPasswordCompare Left: 150 Top: 192
lblPasswordOld Left: 036 Top: 084
lblPasswordNew Left: 036 Top: 138
lblPasswordCompare Left: 036 Top: 192
The control names, which preceded by newline, a bullet and a 1. are controls with default names as they were unintentionally added to the user form.
I want to erase these ghost controls from my forms and wonder, whether anybody has an idea how to separate these controls from the functional and named controls.
Sometimes I can just select a control and pull it to another location to identify the ghost control behind it. The bulleted controls further up escaped my efforts. Any advice, please?