Results 1 to 2 of 2

Thread: ListCount (A2K)

  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Newbury, Berkshire, England
    Thanked 0 Times in 0 Posts

    ListCount (A2K)

    I have a combo box whose row source is based on a query. This query gets some of its information from other combo boxes on the form. Sometimes the combo box is empty when opened because the selections made are not valid.

    When the combo box is empty of rows, I want to run a different routine. I found the following code in the help file which I have altered to suit. I have tried using it in the "before update" event and the "on change" event of the combo box in question, but I can't seem to get it to work.

    I would be very grateful for some help with this.

    Private Sub cboSelectPrice_Change()
    Dim ListControl As Control

    Set ListControl = Me.cboSelectPrice

    With ListControl
    If .ListCount < 1 Then
    msgMessage "Test"
    End If
    End With
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: ListCount (A2K)

    Test the combobbox in the GotFocus event of the combobox itself or possibly in the AfterUpdate event of one of the other controls. It's hard to give you exact instructions without knowing more about what you're doing. I'm not sure why you're setting an object variable like that since you could just as easily have done this:

    With Me.cboSelectPrice
    If .ListCount = 0 Then
    End With

    If you're going to set an object variable, there's no point in declaring it as a control rather than as a combobox unless you plan to use the routine to handle more than just comboboxes, which isn't likely if you put it in one of the control's own event procedures.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts