That is what I am trying to do right now though, add a default value into the combo box. For example, I was Service_Type to always show "Consulting Service" when form opens. I just wanted to clarify in case it wasn't clear.
I think the real problem I am facing is that I can't figure out what the code is naming things.
Here are my column headers: IC_Name, Opportunity, Work Order Number, Cost Center, Service_Type, Department, Hours used per week
Where IC_Name, Opportunity, Service_Type, and Department have named ranges that cause them to be comboboxes.
Here is the coding that is populating them. I cut out as much as I could, but thought this was necessary to help with discovering the names:
Set NewLabel = CurrentFrame.Controls.Add("forms.label.1")
With NewLabel
.Caption = Application.WorksheetFunction.Clean(DatabaseRange.Cells(1, j)
End With
ModifiedName = Application.Substitute(NewLabel.Caption, " ", "_")
If NameHasData(ModifiedName) Then
Set NewControl = CurrentFrame.Controls.Add("forms.combobox.1")
ComboBoxOptions = UNIQUEITEMS(Worksheets(Range(ModifiedName).Parent.Name).Range(ModifiedName))
If IsArray(ComboBoxOptions) Then NewControl.List = ComboBoxOptions
Else
'Add a TextBox
Set NewControl = CurrentFrame.Controls.Add("forms.textbox.1")
End If
With NewControl
.Top = VerticalPosition
.Left = FieldWidth + 6
.Height = 16
.Font.Size = 8
.Tag = "EntryControl"
End With
VerticalPosition = VerticalPosition + 18 'increment
Next j
Here is a picture of what it looks like. It is creating it the way I want it, just can't figure out the names of the combobox/texbox to set default values
DataEntryFormPic.jpg
Bookmarks