|
|
I have a form with a subform that is initially invisible. The user enters a value on the main form, and the AfterUpdate event makes the subform visible (the entered value is also used in a calculation within the query that feeds the subform).
Problem is, the subform opens to a blank screen, nothing displayed. If I go to design view, then back to form view, then change the entered value again, the subform finally appears with data. The query itself is executing correctly, I can run it and see the correct data, but for some reason the subform won't display properly.
I've experimented around with {my subform}.Requery, no difference.
Any suggestions/explanations for this odd behavior?
|
|
LarryP wrote:
[Quoted Text] >I have a form with a subform that is initially invisible. The user enters a >value on the main form, and the AfterUpdate event makes the subform visible >(the entered value is also used in a calculation within the query that feeds >the subform). > >Problem is, the subform opens to a blank screen, nothing displayed. If I go >to design view, then back to form view, then change the entered value again, >the subform finally appears with data. The query itself is executing >correctly, I can run it and see the correct data, but for some reason the >subform won't display properly. > >I've experimented around with {my subform}.Requery, no difference.
How are the subform's records linked to the main form text box?
If it's via a criteria in the subform's record source query, then using Requery in the AfterUpdate event should work.
If it's via the subform control's Link Master/Child properties, it should be automatic.
-- Marsh MVP [MS Access]
|
|
Well, I've tried it both ways and get the same disappointing results. Here's the rather complicated sequence of events: Form A contains a Combo box called cmbJobNo. Selecting a Job opens (makes visible) subform A-1 with some details about the selected job. If the user wants to change the job quantity, a button on A-1 opens form B. Control B!txtJobNo is populated by an expression that refers back to A!cmbJobNo. On Form B the user enters a new quantity, and the AfterUpdate event opens (makes visible) subform B-1. The query behind B-1 again uses A!cmbJobNo as a criterion, AND B-1 is master/child linked to B by txtJobNo/JobNo.
Hope you followed all that. The problem, as I said, is that when made visible, B-1 is blank despite the master/child setup and the requery statement shown below. The only thing I've found so far that makes it display correctly is to go to design view, then back to form view, then change the new quantity value and hit <Enter> again -- presto, B-1 appears and is properly populated.
Here's the bit of VBA; Me in this case is Form B. I've tried putting this in the AfterUpdate event and in the Exit event of the control where the user enters a new quantity, same bad results both ways. Any suggestions welcome.
Me!subfrmKitAddbacks.Visible = True Me!subfrmKitAddbacks.Requery
"Marshall Barton" wrote:
[Quoted Text] > LarryP wrote: > > >I have a form with a subform that is initially invisible. The user enters a > >value on the main form, and the AfterUpdate event makes the subform visible > >(the entered value is also used in a calculation within the query that feeds > >the subform). > > > >Problem is, the subform opens to a blank screen, nothing displayed. If I go > >to design view, then back to form view, then change the entered value again, > >the subform finally appears with data. The query itself is executing > >correctly, I can run it and see the correct data, but for some reason the > >subform won't display properly. > > > >I've experimented around with {my subform}.Requery, no difference. > > > How are the subform's records linked to the main form text > box? > > If it's via a criteria in the subform's record source query, > then using Requery in the AfterUpdate event should work. > > If it's via the subform control's Link Master/Child > properties, it should be automatic. > > -- > Marsh > MVP [MS Access] >
|
|
Thanks, Rick (and Marshall). I've discovered the problem -- dink around long enough and that often happens. The query feeding B-1 involves an expression that uses the modified job quantity entered by the user. I had that control empty (null) until the user provided a value, so the query was producing no results. Defaulting that control to show the original job quantity initially satisfied the query, and B-1 displayed just fine after that. Whew! Thanks for your help, guys.
"Rick Brandt" wrote:
[Quoted Text] > On Wed, 26 Nov 2008 05:09:01 -0800, LarryP wrote: > > > Well, I've tried it both ways and get the same disappointing results. > > Here's the rather complicated sequence of events: Form A contains a > > Combo box called cmbJobNo. Selecting a Job opens (makes visible) > > subform A-1 with some details about the selected job. If the user wants > > to change the job quantity, a button on A-1 opens form B. Control > > B!txtJobNo is populated by an expression that refers back to > > A!cmbJobNo. On Form B the user enters a new quantity, and the > > AfterUpdate event opens (makes visible) subform B-1. The query behind > > B-1 again uses A!cmbJobNo as a criterion, AND B-1 is master/child linked > > to B by txtJobNo/JobNo. > > Are you saving the record in Form B before you display the subform? > Also, if you have the Master/Child links set up as you describe then the > query for subform B-1 does not need to have A!cmbJobNo as critria. > > -- > Rick Brandt, Microsoft Access MVP > Email (as appropriate) to... > RBrandt at Hunter dot com >
|
|
|