Requery SubForm

  • Thread starter Thread starter Larry Salvucci
  • Start date Start date
L

Larry Salvucci

I have a subform that is filtered by a combo box on my main form. The combo
box allows the users to select a year and then all the records within that
year will appear on the subform. I have the default of my combo box set to
"Year(Date())" so when the form is opened it will already show the records
for the current year. I also have some textboxes on my main form the do some
calculations based on the records on my subform. The problem is that when I
open the form and there are records on the subform the calculation controls
will not calculate until I select a year in the combo box. There is a value
already in the combo box based on the default that I set. How come these
calculations won't calculate since there is data already filtered on my
subform when I open my main form? The only way they will calculate is if I
select the year again even though it's already set with a default.
 
Larry,
this often happens when we use default values.
If you have code on the after update event of the combo, you can try putting
code like this in the form's load event
Call Me.TheComboName_AfterUpdate

Jeanette Cunningham
 
Hi Jeanette,

I just tried it and now I'm getting a compile error: Invalid use of property.

Here's what I put on the load event:

Call Me.cboYearSelect.AfterUpdate
 
If you do have an after update event for cboYearSelect
change the . between cboYearSelect and AfterUpdate to
an underscore like this:
cboYearSelect_AfterUpdate

You can find the sub for the after update and copy the relevant part of its
first line, then just put Call followed by a space in front of it.

Jeanette Cunningham
 
That didn't work either. Now I'm getting a "Method or data member not found"
message.

This is what tried this time:

Call Me.cboYearSelect_AfterUpdate
 
I forgot to take the "Me." out of the line. Now it works. This is what I used:

Call cboYearSelect_AfterUpdate

Thanks for your help!
Larry
 
Back
Top