Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling MySubform.Requery from another subform event 1

Status
Not open for further replies.

rcoutts

Technical User
Sep 5, 2001
60
US
I have a Time card form that has two subforms. One subform, "HoursSubform," contains the table that contains the hours, e.g.,
Code:
    Job     Mon Tue Wed Thu Fri Sat Sun Total
    ------- --- --- --- --- --- --- --- -----
    Smith   6.0     8.0 5.0 7.0         26.0
    Jones   2.0 8.0     3.0 1.0         14.0
The second subform, "QuerySubform," has a Query that totals up the hours --
Code:
    Mon Tue Wed Thu Fri Sat Sun Total
    --- --- --- --- --- --- --- -----
    8.0 8.0 8.0 8.0 8.0         40.0
I want to update the Query Subform every time the user changes their daily hours. I created a button on the TimeCard form the runs QuerySubform.Requery on the OnClick event. It works great, except I don't want the user to have ato click a button every time they want to update their hours. I'd rather update when the user changes a value in HoursSubform by running QuerySubform.Requery on the OnChange event, or another equivalent event. The trouble I'm having is that it doesn't appear that HoursSubform can 'see' QuerySubform because I'm getting a run-time error "Object Required" when it hits the line that references QuerySubform.

Is there a way to call QuerySubform from another subform and not from the main form? If there's an alternative way to accomplish this, I'm all ears.

Thanks!
Rich
 
Rich,

You say, "I'm getting a run-time error "Object Required" when it hits the line that references QuerySubform.", but you don't say what that line is.

I'll assume that you've tried
Code:
QuerySubForm.Requery
on the Change, BeforeUpdate & AfterUpdate events of HoursSubForm.

Try
Code:
Form_TimeCard.QuerySubForm.Requery
instead.

I'm not sure, but I believe that Access is looking for QuerySubForm as an object in HoursSubForm.

If this doesn't work, see if you can call the Click Event of your command button from the subform:
Code:
Form_TimeCard.CmdButton_Click
in the change (et al) events of the HoursSubform.

HTH


John
 
I ran into the same problem!

Unfortunately the proposed solution doesn't work :(

Anyone has another suggestion?

KLaus
 
What's missing is the 1st object has to be the database itself, followed by the main form, subform1, etc., etc. E.g., In my case where my database is "TimeCard.mdb" what worked was:

TimeCard.Form_TimeCard.QuerySubForm.Requery

In VB when you type the name of the database and then the "." a drop down list of valid forms will appear. You know you're on the right track then.

Regards,
Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top