PDA

View Full Version : Refreshing list box on subform on record change



Austin
09-11-2008, 07:10 AM
So when I change the record of the main form the subform changes but a lstbox is not updating on the subform.

I've tried requerying the listbox on subform_afterchange, but that doesn't work. I've also tried requering then doing DoCmd.FindRecord Me.ID but that didn't work either.

CreganTur
09-11-2008, 07:32 AM
I'm guessing that you have set the Row Source for your list box via the properties sheet.

Setting the Row Source via VBA would be the most dynamic option I could think of. Just hard-code your SQL statement for the rowsource and in its WHERE clause reference the value of the field(s) on your main or subform that will allow you to get the records in the list box you want. Use that as a part of your SubForm_AfterChange event and it should work for you.

Austin
09-11-2008, 12:44 PM
I'm having some major issues trying to get this to work. I can't find any property that changes when I change the mainform record. The ID field is changing but if I put any code in that textbox_afterupdate it doesn't do anything. I've tried putting just a simple Msgbox TEST there and it doesnt do anything. I've also tried putting it on subform_afterchange. Where can I put some code that will be activated when the main record changes? The ID text box on the subform changes but it doesn't run any code.

Any ideas?

CreganTur
09-11-2008, 01:19 PM
Have you considered using the Form's Current event?