Private Sub UserForm_Initialize()
Dim i As Integer
Me.BackColor = RGB(249, 242, 228)
Me.fraSheet.BackColor = RGB(241, 245, 253)
Me.fraButtons.BackColor = RGB(241, 245, 253)
Me.fraMail.BackColor = RGB(241, 245, 253)
Me.tb16.BackColor = RGB(185, 211, 238)
Me.tb17.BackColor = RGB(185, 211, 238)
Me.cmdAdd.BackColor = RGB(255, 153, 153)
Me.cmdDone.BackColor = RGB(255, 153, 153)
Me.cmdCancel.BackColor = RGB(255, 153, 153)
Me.cmdClear.BackColor = RGB(255, 153, 153)
Me.cmdData.BackColor = RGB(255, 153, 153)
Me.cmdSearch.BackColor = RGB(255, 153, 153)
Me.cmdSend.BackColor = RGB(255, 153, 153)
' Set a Range variable to represent the Data
Set rData = DATA.Cells(lOffset, 1).CurrentRegion
' The number of Colimns or Fields in the Data
iCol = rData.Columns.Count
'check that the DataBase fits the ListBox
If iCol > 24 Then
MsgBox "This form is not suitable for Databases with more than 24 Fields", vbCritical, FrmCap
iCol = 24
End If
'populate labels & enable TextBoxes
' iCol is the number of active Labels & TextBoxes required
' Limit this run to the first 15 column headings
' For iX = 1 To iCol
For iX = 1 To 15
Me("lbl" & iX).Caption = rData.Cells(1, iX).Value
Me("lbl" & iX).BackColor = RGB(224, 238, 224)
Me("tb" & iX).Enabled = True
Me("tb" & iX).BackColor = lActive
Next iX
Me.lblTo.BackColor = RGB(224, 238, 224)
Me.lblSubj.BackColor = RGB(224, 238, 224)
Me.lblMsg.BackColor = RGB(224, 238, 224)
Me.lblAttach.BackColor = RGB(224, 238, 224)
' When the form initialises, cmdAdd ("Add New Record") is enabled.
' Add the ControlTipText for "Add New Record"
Me.cmdAdd.ControlTipText = "Create a new record by infilling the fields as necessary. When complete, click this button."
' Add the Company Name & Address label
Me("lbl16").Caption = "Company Name & Address:"
Me("lbl16").BackColor = RGB(224, 238, 224)
Me("tb16").Enabled = True
Me("tb16").BackColor = lActive
With Me
'width and height have been declared as Constants, _
.Width = StartWidth + 665 'XXXXX
.Height = StartHeight + 350
'we need the add button to be enabled
.cmdAdd.Enabled = True
.Caption = FrmCap
'set the number of Columns to display in the listbox
.lbxData.ColumnCount = iCol
.cboSort.List = Application.WorksheetFunction.Transpose(rData.Rows(1))
.cboSort.ListIndex = 0
'don't allow ID # to be changed
.tb1.Enabled = False
'add the next ID #
.tb1.Value = WorksheetFunction.Max(rData.Columns(1)) + 1
' Enable/disable the appropriate buttons
' Further work here
End With
End Sub
I'd be grateful for further help please.