Advertisement

09.28.2007 at 05:14PM PDT, ID: 22860878
[x]
Attachment Details

VBA in Access: Refreshing a listbox's list

Asked by wthero in Access Coding/Macros, Microsoft Access Database, Access Forms

Tags: vba, access, list, refresh, box

I'm trying to figure out the best way to refresh data in a dropdown list on a form.  The dropdown list contains customers, and the form that the dropdown list is on has a button to click on to open the "edit customers" form.  When I click on that button and add a new customer, then close out the "edit customer" form, the name doesn't appear in the dropdown list until I close and reopen the original form.  What can I do to refresh the list when the other form closes out (or if I have to, have an update button next to the dropdown list).

I tried this code (linked to a button), to close and reopen the form at the same record, but it doesn't work.

Private Sub Update_Click()
    'Store the ID of the current record, so we can come back to it
    Dim Product As String
    Product = ProductID
    'Close and reopen the form at the record to refresh the customer's column
    DoCmd.Close
    DoCmd.OpenForm "Products", WhereCondition:="ProductID=" & Product
End Sub

The reason it doesn't work is it reopens the form, but gives me a dialog box to enter the "ProductID" into, rather than going to the record that contains "Product".

Any help is appreciated, give me things to try!Start Free Trial
[+][-]09.28.2007 at 05:34PM PDT, ID: 19982586

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.28.2007 at 05:49PM PDT, ID: 19982609

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft Access Database, Access Forms
Tags: vba, access, list, refresh, box
Sign Up Now!
Solution Provided By: jefftwilley
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628