Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    list box code failure (2000 all updates)

    The form is called frmFamilies. The problem lies with some of the code behind a list box on the form.

    I tried to include everything here but received a message saying that the message was too long and should be attached in a text file.

    Therefore attached is an .rtf document.


    Tom

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: list box code failure (2000 all updates)

    When you change the selection do you requery the list box?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: list box code failure (2000 all updates)

    You add the final closing parenthesis ) to the WHERE clause only if Criteria is not empty. You should get an error message if Criteria is empty (i.e. if you select the first item from the list box).

    I cannot discern why the code would toggle the Discontinued state. Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  4. #4
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: list box code failure (2000 all updates)

    Patt
    No, I don't requery the list box upon changing the selection. But doing so makes no difference.

    For some reason, if I am on the Discontinued records, as soon as I make a selection in the list box, the recordset switches to the Active bunch.

    Hans
    I will work out a stripped down copy and post it.

    Tom

  5. #5
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: list box code failure (2000 all updates)

    Hans
    Here is a stripped down copy. I had to convert it to Access 97 to get it below 100k

    You will notice that when you are in Active families (Discontinued = No) the list box changes work fine. And when you click the radio button to go to Discontinued Families the Discontinued records display properly (Discontinued box is checked). But when you make a selection (any selection) in the list box the records revert to the Active set.

    Funny thing, I used this exact same code in an earlier design of this project and it worked perfectly. There has to be a glitch somewhere, but I have spent hours and not found it.

    Tom

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: list box code failure (2000 all updates)

    I can't make head or tails of the way you set up optActive and optDiscontinued. One of them (optDiscontinued) is toggled between True and Null, the other is always True. Instead of two independent option buttons, you should either use an option group with two option buttons (and look at the value of the option group), or use a toggle button.

  7. #7
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: list box code failure (2000 all updates)

    Well, Hans...your not being able to make heads or tails of the option buttons setup was the key. One line behind optDiscontinued was incorrect. I had pored over this sucker for hours and didn't find it.

    Two lines were
    Me.optDiscontinued.Visible = False
    Me.optActive = True

    The line in bold print is incorrect and should be
    Me.optDiscontinued = True

    Making that correction makes the Discontinued recordset work properly.

    So I'm half-way home.

    The combo box "cboFind" isn't performing properly in the Discontinued bunch, but that should be fixable.

    I will take a look at the Option Group or Toggle button possibilities.

    Thanks for finding the needle in the haystack. It always helps to have a fresh pair of eyes.

    Tom

  8. #8
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: list box code failure (2000 all updates)

    Hans
    I have fixed the "cboFind" combo box, so everything works.

    But a question:
    You said that I should use an Option Group rather than option radio buttons, or possibly a toggle button. I have not often bothered with a toggle button, but I can see merit in this case. As for radio buttons vs. an option group, isn't that really a matter of choice...or is the option group far preferable for some particular reason? The same coding would still be required behind the option group choices as now exists behind the radio buttons.

    Tom

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: list box code failure (2000 all updates)

    If you place option buttons in an option group, you have to write less code, for clicking an option button turns that one on and all others in the same group off, so you don't have to take care of that yourself. And instead of writing an event procedure for each individual option button, you write only one event procedure for the option group. You can (and should) assign a unique Option Value to each option button in the group. The value of the option group is equal to the Option Value of the currently selected option button.

    Example: for an option group grpChoice with two option buttons having Option Value 1 and 2, respectively, the code would look like this:

    Private Sub grpChoice_AfterUpdate()
    Select Case Me.grpChoice
    Case 1
    ' code to execute if first option button is selected
    ...
    Case 2
    ' code to execute if second option button is selected
    ...
    End Select
    End Sub

Posting Permissions

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