Record Count in Combo Box???

XLEAccessGuru

XLEGuru
Local time
Today, 14:42
Joined
Nov 17, 2006
Messages
65
This is a really stupid question but I gotta ask.

Does anyone know some VBA that will count records in a combo box on a subform? I need to do this because some of my requestors in the DB are responsible for more than one department. Their names auto fill, but I need to remind them to select a department if the DEPARTMENT combo box contains more than one value in the drop down list. The challenge is that the combo box is on a subform. Current code returns a "Object doesn't support this property or method" error. Here's the code that's currently using the "RecordCount" property - is there something else I can do here to determine the # of values in this combo box?


Code:
If Forms![frmCustomerRequest]![REQUESTOR_INFORMATION].Form![DEPT_Name].RecordCount > 1 Then
    MsgBox "You are responsible for more than one DEPARTMENT.  " _
        & "Please select a department from the drop-down list. ", vbInformation, "Department Validation"
End If
 
Code:
Me.YourTextBoxNameHere = Me.YourComboBoxNameHere.ListCount

and if you have the headers enabled in the combo, then

Code:
Me.YourTextBoxNameHere = Me.YourComboBoxNameHere.ListCount - 1
 
Thanks a ton - I knew it was simple, but it's one of those brain-train wrecks where you're so close to a project that the simple things elude you....

Thank you very much!
 
Thanks, was searching for this function!
GREAT BOARD! NICE SEARCH FUNCTION :P
 

Users who are viewing this thread

Back
Top Bottom