Requery a subform based on a Unbound Tetbo populated On Open

  • Thread starter Thread starter PGPianta
  • Start date Start date
P

PGPianta

Hi,

The main form is called frmSngOrder, which has two subforms
frmSngActivities and frmSngNotes. frmSngNote is filled with records
based on a value of a unbound textbox - txtSelectedActivity, which is
populated by clicking on a record in the frmSngActivities subform.

The idea is that when the main form opens, the ID for the first record
in the frmSngActivities populates the txtSelectActivity. This value is
then userd by the recordsource of the txtSngNote to only show the
related Notes for this Activity.

All works fine when the form is already open. My issue is, I can't get
the records in frmSngNotes to show automatically when the main form and
subforms initially open, it appears that their are no notes until a
user clicks a record (causing the On Click event to kick in)

What event or how can I get the frmSngNotes to Requery only after all
forms are open And the txtSelectedActivity has been updated. The On
Change and After Update event for the txtSelectedActivity don't seem to
fire off when changed via a module...
 
Found a solution...added a frmSngNotes Requery too the Activate event
of the main form...
 
Hi,

The main form is called frmSngOrder, which has two subforms
frmSngActivities and frmSngNotes. frmSngNote is filled with records
based on a value of a unbound textbox - txtSelectedActivity, which is
populated by clicking on a record in the frmSngActivities subform.

The idea is that when the main form opens, the ID for the first record
in the frmSngActivities populates the txtSelectActivity. This value is
then userd by the recordsource of the txtSngNote to only show the
related Notes for this Activity.

All works fine when the form is already open. My issue is, I can't get
the records in frmSngNotes to show automatically when the main form and
subforms initially open, it appears that their are no notes until a
user clicks a record (causing the On Click event to kick in)

What event or how can I get the frmSngNotes to Requery only after all
forms are open And the txtSelectedActivity has been updated. The On
Change and After Update event for the txtSelectedActivity don't seem to
fire off when changed via a module...


That's a fairly complex arangement that I don't have time to
duplicate, but I think the problem is that main form and the
frmSngActivities subform have to go through their Load event
before the txtSngNote subform's data is loaded, which is not
how Access initializes a form subform arrangement.

Take a look the at the main form text box to see if it has
the correct value from the subform when it's first opened.
If it doesn't then use the main form's Load event to requery
frmSngActivities:
Me.frmSngActivities.Requery

If the text box does have the correct value, then I think
you should requery txtSngNote instead:
Me.txtSngNote.Requery
 
Found a solution...added a frmSngNotes Requery too the Activate event
of the main form...


That will work when the form first opens, but, if you should
click to a different form and then click back to this form,
it's Activate event should fire again and reposition the
subform's current record back to its first record. Try
using the main form's Load event.
 
Back
Top