Listbox doesn't update on Requery

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark

    Listbox doesn't update on Requery

    Hello.

    I have a listbox whose rowsource is set to a saved query (call it
    "qry_customer_l ist.") When I add customers to my database, I call the
    listbox Requery method so that the listbox will display the customers that I
    added. Unfortunately, the listbox display does not change. If I close the
    form and reload it, then the listbox will show the new customers.

    Any suggestions on how to fix this?

    Someone suggested there might be a timing issue where my listbox Requery
    happens before the database insert is completed. I tested this by adding a
    command button to call the listbox Requery method. I tried the command
    button numerous times after adding a customer, and the customer still did
    not show up in the listbox.

    Suggestions?

    Thanks
    -Mark


  • Wayne Morgan

    #2
    Re: Listbox doesn't update on Requery

    I take it that you are adding an entry because you went to the listbox and
    the entry wasn't there. If that is the case, manually type the entry into
    the listbox and let the NotInList event activate. In this event, you can add
    the item you just typed in to a new record in the listbox's recordset or
    pop-up a form to fill out the rest of the record is that is needed. Once
    you've added the record, use the command

    Response = acDataErrAdded

    to tell the listbox that new data has been added to the recordset for its
    RowSource. The listbox will automatically update itself.

    Example:


    --
    Wayne Morgan
    MS Access MVP


    "Mark" <nospam@thanksa nyway.org> wrote in message
    news:W_CdnUac8N yk-GjenZ2dnUVZ_t2d nZ2d@w-link.net...[color=blue]
    > Hello.
    >
    > I have a listbox whose rowsource is set to a saved query (call it
    > "qry_customer_l ist.") When I add customers to my database, I call the
    > listbox Requery method so that the listbox will display the customers that
    > I added. Unfortunately, the listbox display does not change. If I close
    > the form and reload it, then the listbox will show the new customers.
    >
    > Any suggestions on how to fix this?
    >
    > Someone suggested there might be a timing issue where my listbox Requery
    > happens before the database insert is completed. I tested this by adding a
    > command button to call the listbox Requery method. I tried the command
    > button numerous times after adding a customer, and the customer still did
    > not show up in the listbox.
    >
    > Suggestions?
    >
    > Thanks
    > -Mark
    >
    >[/color]


    Comment

    • Mark

      #3
      Re: Listbox doesn't update on Requery

      "Wayne Morgan" <comprev_gothro ughthenewsgroup @hotmail.com> wrote:[color=blue]
      >I take it that you are adding an entry because you went to the listbox and
      >the entry wasn't there. If that is the case, manually type the entry into
      >the listbox and let the NotInList event activate.[/color]

      This is a listbox control, not a combobox. I am adding data to the database,
      and that data would be returned by the listbox's underlying rowsource.
      I want the listbox to refresh and display the new data. That doesn't
      happen, not even when I execute the listbox's Requery method.

      Thanks
      -Mark


      Comment

      • Allen Browne

        #4
        Re: Listbox doesn't update on Requery

        Mark, what is the timing of this?

        How are you adding record's to the list box's RowSource table?
        - Executing an Append query?
        - Adding to a Recordset? - ADO or DAO?
        - Entering into a Form?

        Are you sure the record has been written before the requery? For example, is
        it still in the form (not saved) when the Requery happens?

        Does adding a DoEvents give it the chance to catch up?

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia.
        Tips for Access users - http://allenbrowne.com/tips.html
        Reply to group, rather than allenbrowne at mvps dot org.

        "Mark" <nospam@thanksa nyway.org> wrote in message
        news:aqydnSsuLc 0v6mjeRVn-tw@w-link.net...[color=blue]
        > "Wayne Morgan" <comprev_gothro ughthenewsgroup @hotmail.com> wrote:[color=green]
        >>I take it that you are adding an entry because you went to the listbox and
        >>the entry wasn't there. If that is the case, manually type the entry into
        >>the listbox and let the NotInList event activate.[/color]
        >
        > This is a listbox control, not a combobox. I am adding data to the
        > database,
        > and that data would be returned by the listbox's underlying rowsource.
        > I want the listbox to refresh and display the new data. That doesn't
        > happen, not even when I execute the listbox's Requery method.[/color]


        Comment

        • Mark

          #5
          Re: Listbox doesn't update on Requery

          "Mark" <nospam@thanksa nyway.org> wrote:

          Sorry, the problem is not what I thought it was. Apparently my code
          wasn't applying the update to the database, so there was nothing
          new for the listbox to retrieve when I executed its Requery method.

          Thanks for your help.
          -Mark


          Comment

          • Mark

            #6
            Re: Listbox doesn't update on Requery

            Sorry Allen, it was a goof on my part. My database insert
            code wasn't doing what I thought it was doing.

            -Mark


            Comment

            • Wayne Morgan

              #7
              Re: Listbox doesn't update on Requery

              > This is a listbox control, not a combobox.

              Sorry, bad reading.

              --
              Wayne Morgan
              MS Access MVP


              "Mark" <nospam@thanksa nyway.org> wrote in message
              news:aqydnSsuLc 0v6mjeRVn-tw@w-link.net...[color=blue]
              > "Wayne Morgan" <comprev_gothro ughthenewsgroup @hotmail.com> wrote:[color=green]
              >>I take it that you are adding an entry because you went to the listbox and
              >>the entry wasn't there. If that is the case, manually type the entry into
              >>the listbox and let the NotInList event activate.[/color]
              >
              > This is a listbox control, not a combobox. I am adding data to the
              > database,
              > and that data would be returned by the listbox's underlying rowsource.
              > I want the listbox to refresh and display the new data. That doesn't
              > happen, not even when I execute the listbox's Requery method.
              >
              > Thanks
              > -Mark
              >
              >[/color]


              Comment

              Working...