How do I 'repaint' a subfom?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Main form (Form1) subform on Form1 (Form2).
List boxes in both forms , tables are linked.
Form 2 list box has a QUERY to filter records depending on which record is
selected in Form1 list box.
How do I repaint the Form2 (subform) listbox as I move from record to record
in Form1 listbox.
I can do this as 2 separate forms by running a Macro which closes/opens
Form2 every time I click on a record in Form1 listbox.
The relationship between Form1 and Form2 tables is one to many.
 
Using the Current event of the main form and the AfterUpdate event of the
listbox on the mainform you need to requery the listbox on the subform. The
requery code should look something like this:

me.sfrmForm2.form.MyList.requery

replace 'sfrmForm2' above with the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
sfrmForm2.

If the main form's listbox is bound to a field in the main form's rowsource
then putting the code in the main form's current event will ensure that the
subform's listbox is requeried each time record navigation occurs.
 
thank you very much for your help. I have only spent last 3 days trying to
get this to work!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Refresh form while Open 6
Best way to link popup form? 6
subforms/combo boxes 2
Editing subform data from VB 1
problem carrying over values 1
OpenForm? 1
Default value 3
Setting Default Value in List Box 3

Back
Top