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?
Printable View
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?
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.
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,
Is LoadTripListView declared as a Private sub or a Public sub?
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 ....