Update a Listbox after making a change in a field

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

    Update a Listbox after making a change in a field

    Hello... thank you for your time.

    I have a form that has a List box of equipotent records and a sub form
    that will show the data of the equipment select from the list box.

    Is it possible to make a change in the name field in the details, then
    refresh the list box with new name?

    Please help and thanks!

    N. Graves
  • Salad

    #2
    Re: Update a Listbox after making a change in a field

    N. Graves wrote:
    [color=blue]
    > Hello... thank you for your time.
    >
    > I have a form that has a List box of equipotent records and a sub form
    > that will show the data of the equipment select from the list box.
    >
    > Is it possible to make a change in the name field in the details, then
    > refresh the list box with new name?
    >
    > Please help and thanks!
    >
    > N. Graves[/color]

    If refreshing in the main form, and the listbox is called LB1, then
    Me.LB1.Requery
    If the LB is in a main form but called to refresh from a subform
    Forms!MainForm! LB1.Requery

    Comment

    • N. Graves

      #3
      Re: Update a Listbox after making a change in a field

      Thanks you so much for your input. I think I need to add a little
      more to my disruptions. First here is the code that I'm using

      Private Sub CommonName_Afte rUpdate()
      Forms!frm_AddEd it_Equipment_Ma ster.lst_EquipI D.Requery
      End Sub

      Action: When I update this field and move to another field the screen
      will flicker like it is refreshing but nothing happens... If I go
      back to the field and change it again and leave then the list box will
      update but it displays the first change and not the last change.

      I'm guessing that I need to update the record (save the record) before
      I update the list box. I have search help but not able to find the
      command to post the changes to the table before I refresh.

      Can you help me?

      Thanks again!

      N. Graves



      On Thu, 20 May 2004 21:02:27 GMT, Salad <oil@vinegar.co m> wrote:
      [color=blue]
      >N. Graves wrote:
      >[color=green]
      >> Hello... thank you for your time.
      >>
      >> I have a form that has a List box of equipotent records and a sub form
      >> that will show the data of the equipment select from the list box.
      >>
      >> Is it possible to make a change in the name field in the details, then
      >> refresh the list box with new name?
      >>
      >> Please help and thanks!
      >>
      >> N. Graves[/color]
      >
      >If refreshing in the main form, and the listbox is called LB1, then
      > Me.LB1.Requery
      >If the LB is in a main form but called to refresh from a subform
      > Forms!MainForm! LB1.Requery[/color]

      Comment

      • Salad

        #4
        Re: Update a Listbox after making a change in a field

        N. Graves wrote:[color=blue]
        > Thanks you so much for your input. I think I need to add a little
        > more to my disruptions. First here is the code that I'm using
        >
        > Private Sub CommonName_Afte rUpdate()
        > Forms!frm_AddEd it_Equipment_Ma ster.lst_EquipI D.Requery
        > End Sub[/color]
        [color=blue]
        >
        > Action: When I update this field and move to another field the screen
        > will flicker like it is refreshing but nothing happens... If I go
        > back to the field and change it again and leave then the list box will
        > update but it displays the first change and not the last change.[/color]
        [color=blue]
        >
        > I'm guessing that I need to update the record (save the record) before
        > I update the list box. I have search help but not able to find the
        > command to post the changes to the table before I refresh.[/color]

        That would appear to be correct if the listbox's rowsource are records
        in a table and not a value list or user defined list. If you haven't
        committed the changes (saved record) and the rowsource is from a table,
        it certainly is not going to have that in the listbox.

        You could enter a command like
        Me.Dirty = False
        to save the record just prior to requerying. Another option is to put
        the Requery in the AfterUpdate event of the form...IOW, after the record
        has been saved. I don't know why it needs to be in the listbox
        immediately after a field is changed.

        If you absolutely, positively need to have this when the field changes
        and not when the record changes you have a couple of options....make the
        rowsource a value list and concatenate the data to display. There is a
        caveat using this method...I think the string length for a value list is
        2048 so you can't display too many rows. Or, write a UserDefine
        function. If you are willing to futz with that (maybe do some searches
        at Google groups, *Access*, for userdefine callbacks, you should get
        plenty of code to assist.



        [color=blue]
        >
        > Can you help me?
        >
        > Thanks again!
        >
        > N. Graves
        >
        >
        >
        > On Thu, 20 May 2004 21:02:27 GMT, Salad <oil@vinegar.co m> wrote:
        >
        >[color=green]
        >>N. Graves wrote:
        >>
        >>[color=darkred]
        >>>Hello... thank you for your time.
        >>>
        >>>I have a form that has a List box of equipotent records and a sub form
        >>>that will show the data of the equipment select from the list box.
        >>>
        >>>Is it possible to make a change in the name field in the details, then
        >>>refresh the list box with new name?
        >>>
        >>>Please help and thanks!
        >>>
        >>>N. Graves[/color]
        >>
        >>If refreshing in the main form, and the listbox is called LB1, then
        >> Me.LB1.Requery
        >>If the LB is in a main form but called to refresh from a subform
        >> Forms!MainForm! LB1.Requery[/color]
        >
        >[/color]

        Comment

        • N. Graves

          #5
          Re: Update a Listbox after making a change in a field

          Thank you for your insight!

          That worked with the Dirty = False.

          I have posted another question title "Tab Control Display issue" If
          you have an extra moment to take a look and response. I'll owe you a
          one

          Thanks

          N. Graves

          On Fri, 21 May 2004 17:27:50 GMT, Salad <oil@vinegar.co m> wrote:
          [color=blue]
          >N. Graves wrote:[color=green]
          >> Thanks you so much for your input. I think I need to add a little
          >> more to my disruptions. First here is the code that I'm using
          >>
          >> Private Sub CommonName_Afte rUpdate()
          >> Forms!frm_AddEd it_Equipment_Ma ster.lst_EquipI D.Requery
          >> End Sub[/color]
          >[color=green]
          >>
          >> Action: When I update this field and move to another field the screen
          >> will flicker like it is refreshing but nothing happens... If I go
          >> back to the field and change it again and leave then the list box will
          >> update but it displays the first change and not the last change.[/color]
          >[color=green]
          >>
          >> I'm guessing that I need to update the record (save the record) before
          >> I update the list box. I have search help but not able to find the
          >> command to post the changes to the table before I refresh.[/color]
          >
          >That would appear to be correct if the listbox's rowsource are records
          >in a table and not a value list or user defined list. If you haven't
          >committed the changes (saved record) and the rowsource is from a table,
          >it certainly is not going to have that in the listbox.
          >
          >You could enter a command like
          > Me.Dirty = False
          >to save the record just prior to requerying. Another option is to put
          >the Requery in the AfterUpdate event of the form...IOW, after the record
          >has been saved. I don't know why it needs to be in the listbox
          >immediately after a field is changed.
          >
          >If you absolutely, positively need to have this when the field changes
          >and not when the record changes you have a couple of options....make the
          >rowsource a value list and concatenate the data to display. There is a
          >caveat using this method...I think the string length for a value list is
          >2048 so you can't display too many rows. Or, write a UserDefine
          >function. If you are willing to futz with that (maybe do some searches
          >at Google groups, *Access*, for userdefine callbacks, you should get
          >plenty of code to assist.
          >
          >
          >
          >[color=green]
          >>
          >> Can you help me?
          >>
          >> Thanks again!
          >>
          >> N. Graves
          >>
          >>
          >>
          >> On Thu, 20 May 2004 21:02:27 GMT, Salad <oil@vinegar.co m> wrote:
          >>
          >>[color=darkred]
          >>>N. Graves wrote:
          >>>
          >>>
          >>>>Hello... thank you for your time.
          >>>>
          >>>>I have a form that has a List box of equipotent records and a sub form
          >>>>that will show the data of the equipment select from the list box.
          >>>>
          >>>>Is it possible to make a change in the name field in the details, then
          >>>>refresh the list box with new name?
          >>>>
          >>>>Please help and thanks!
          >>>>
          >>>>N. Graves
          >>>
          >>>If refreshing in the main form, and the listbox is called LB1, then
          >>> Me.LB1.Requery
          >>>If the LB is in a main form but called to refresh from a subform
          >>> Forms!MainForm! LB1.Requery[/color]
          >>
          >>[/color][/color]

          Comment

          Working...