Is there any way I can find out how many rows in a combo box?

S

Stapes

Hi

I have a combo box that displays all the records in my database that
match a record being imported, using the postcode. Is there any way I
can determine, for the current record, how many rows are in the combo
box. i.e If there are > 1 row displayed.

Stapes
 
P

Pieter Wijnen

Totaly useless example:

Private Sub Form_Current()
Dim Cb As Access.ComboBox

set Cb = Me.Combo0
Debug.Print Cb.ListCount
End Sub

HTH

Pieter
 
U

UpRider

Steve, put this in the form's current event:
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = Combo10.RowSource
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.RecordCount > 0 Then
rst.MoveLast
txtComboCount = rst.RecordCount
End If
combo10 is the name of your combobox,
txtComboCount is a textbox that will display the count.

UpRider
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top