When I try to open a form in Access I get an error message that says You entered the control name 'col1,' which is already in use. The code where this error happens is at Forms(frm)(i+16).Name="col" & Format(i, "0")below. What does this error mean? And how can i correct it?
Sub SetGridColumns(frm As String, FirstDay As Variant, LastDay As Variant)
Dim i As Integer
' Sets column headings for all shown dates in crosstab fsub
DoCmd.OpenForm frm, acDesign, , , , acHidden
For i = 0 To 7
' Avoid control name conflicts by renaming them to col1 ...
' The dirty constant 16 is the item number of the last non-column item.
**Forms(frm)(i + 16).Name = "col" & Format(i, "0")**
Next i
For i = 0 To 7
' Now give the columns the right control name and control source
Forms(frm)(i + 16).ControlSource = Format(FirstDay + i, "mm-dd")
Forms(frm)(i + 16).Name = Format(FirstDay + i, "mm-dd")
Next i
DoCmd.Close acForm, frm, acSaveYes
End Sub