Full Version: List box only updates first time
UtterAccess Discussion Forums > Microsoft® Access > Access Q and A
ElAmericano
I have a form with several subforms. One of the subforms is for addresses. One of the subforms is for invoice data. The invoice data includes a drop down list in order to select one of the addresses in the adress subform.

At first I had to open and close my main form in order to get the list to update. Then I read about "Me.dropdownlist.Requery"

First I tried adding the code as an "AfterUpdate" command to the address subform but that didn't work, probably because I have the list on another subform.

So I tried adding this code directly as an "On Click" event of the actual drop down list. This works......sort of.

The first new address that I add to the form gets updated in the list but each address after the first one doesn't.

Why am I getting a result only on the first new address that I add?

Thank you for any light you can shed on the problem.

El Americano
ubergud
You can put the code on on the AddressListBox_AfterUpdate() Event to requery the other subform, the key is how you reference it. I cannot recall the syntax off the top of my head (there was something different about it), but you should find something like this:

CODE
Private Sub AddressListBoxOnAddressSubForm_AfterUpdate()
  Dim MainForm As Form
  Dim InvoiceSubForm As Form
  Set MainForm = Me.Parent
  Set InvoiceSubForm = MainForm!OtherSubForm
  InvoiceSubForm.AddressListBoxOnInvoiceSubForm.Requery
End Sub


I believe there should be a help topic on how to reference a control on a SubForm, which should lead you toward the syntax you are looking for.
theDBguy
Here's a link to The Access Web. HTH.
ElAmericano
I've tried requerying the list box from the address subform with the information on "The Access Web" but I'm still only getting an update with the first new address that I add. Each address after the first address doesn't get updated.

This of course is better than no updates at all, but I can't figure out why it doesn't requery every time I add a new address.
theDBguy
Can you convert your db into 2003, so I can take a look at it? Thanks.
ElAmericano
Ok, I got it, but just in case there's a better way, here is 2003 version of the databse. Everything is built off of the "mainform"

In the end, i've used the following code on the dropdownlist i've named "invoiceaddr" as en "On Click" event: invoiceaddr.requery

The reason that my list only updated with the first address that I added but not with consecutive addresses, is that I needed a refresh which I've added to the after_update of the address_type subform.

Thanks for the pointers.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.