Results 1 to 5 of 5

Thread: listbox question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    166

    listbox question

    After I have inserted a trip into the access database and closed that form, I need the trip listview on the main form to refresh and show all the trips, including the one that was newly added.

    What is the best way to do this?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: listbox question

    We would need more details, including what you are attempting and what is not working. Not enough info from what you posted I'm afraid.

    But if you already have code to fill the listview, why not just call it again after you update the database? Another option is to simply append a new entry to the listview after updating the database, vs reading the entire database again. Just some thoughts.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    166

    Re: listbox question

    I have a function that populates the listview called loadTripListview()

    But what I am not sure what form event to put the call in.

    Here is basically what happens
    1) program starts and the main form loads. The trip Listview shows all the available trips
    2) the user clicks an Add Trip button A second form opens and they enter the data in that second form and add the new trip to the database
    3) the second form closes and now the listview on the main form needs updated.

    thanks,

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: listbox question

    Is LoadTripListView declared as a Private sub or a Public sub?

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: listbox question

    Depending on what you want to do.

    1. If you want to re-read the entire database and repopulate your listview
    a. Open the second form modally. frmTripInput.Show vbModal, Me
    b. The next line of code will not execute until that form is closed/made invisible. On the next line of code, repopulate your listview. This method will repopulate even if the user hits cancel on that other form. Though some things can be done to prevent that.

    2. Make your function that populates the listview a Public function in your main form. From the trips form, call it> MainForm.LoadTripListView for example.

    3. If you only want to append the new trip to the listview, you can do that directly from your trips form. MainForm.ListView1.ListItems.Add ....
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

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



Click Here to Expand Forum to Full Width