ryancgarrett
Board Regular
- Joined
- Jun 18, 2011
- Messages
- 122
I have a form with a combobox on it and use the following code to set the rowsource.
When I first use it everything works great, but after I clear the form the combobox shows up with the appropriate amount of blank spaces, but no visible text. Here is the code I use to clear the form.
Does anyone see anything wrong with what I am doing here? If it helps, here is a picture of my form:
Code:
Sub populateComboBox()
Dim lr As Long
With Sheets("Data Sheet")
lr = BlankRow("Data Sheet", 2, 4) - 1
frmTransactionEntry.cbxAccount1.RowSource = .Range("D2:D" & lr).Address(False, False)
frmTransactionEntry.cbxAccount2.RowSource = .Range("D2:D" & lr).Address(False, False)
frmTransactionEntry.cbxAccount3.RowSource = .Range("D2:D" & lr).Address(False, False)
frmTransactionEntry.cbxAccount4.RowSource = .Range("D2:D" & lr).Address(False, False)
frmTransactionEntry.cbxAccount5.RowSource = .Range("D2:D" & lr).Address(False, False)
frmTransactionEntry.cbxAccount6.RowSource = .Range("D2:D" & lr).Address(False, False)
End With
End Sub
'Function to find the end of a list
Function BlankRow(sName As String, sRow As Integer, sCol As Integer) As Integer
Do Until Sheets(sName).Cells(sRow, sCol).Value = Empty
sRow = sRow + 1
Loop
BlankRow = sRow
End Function
When I first use it everything works great, but after I clear the form the combobox shows up with the appropriate amount of blank spaces, but no visible text. Here is the code I use to clear the form.
Code:
Sub ClearTransactionEntry()
frmTransactionEntry.tbxDate.Value = Date
frmTransactionEntry.tbxAmount1.Value = FormatCurrency(0, 2)
frmTransactionEntry.tbxAmount2.Value = FormatCurrency(0, 2)
frmTransactionEntry.tbxAmount3.Value = FormatCurrency(0, 2)
frmTransactionEntry.tbxAmount4.Value = FormatCurrency(0, 2)
frmTransactionEntry.tbxAmount5.Value = FormatCurrency(0, 2)
frmTransactionEntry.tbxAmount6.Value = FormatCurrency(0, 2)
frmTransactionEntry.cbxAccount1.Value = " "
frmTransactionEntry.cbxAccount2.Value = " "
frmTransactionEntry.cbxAccount3.Value = " "
frmTransactionEntry.cbxAccount4.Value = " "
frmTransactionEntry.cbxAccount5.Value = " "
frmTransactionEntry.cbxAccount6.Value = " "
frmTransactionEntry.tbxSumOfDebits.Value = " "
frmTransactionEntry.tbxSumOfCredits.Value = " "
frmTransactionEntry.tbxDescription.Value = " "
frmTransactionEntry.optDebit1.Value = False
frmTransactionEntry.optDebit2.Value = False
frmTransactionEntry.optDebit3.Value = False
frmTransactionEntry.optDebit4.Value = False
frmTransactionEntry.optDebit5.Value = False
frmTransactionEntry.optDebit6.Value = False
frmTransactionEntry.optCredit1.Value = False
frmTransactionEntry.optCredit2.Value = False
frmTransactionEntry.optCredit3.Value = False
frmTransactionEntry.optCredit4.Value = False
frmTransactionEntry.optCredit5.Value = False
frmTransactionEntry.optCredit6.Value = False
End Sub
Does anyone see anything wrong with what I am doing here? If it helps, here is a picture of my form: