Requery a form with text boxes as queries as data source

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Requery a form with text boxes as queries as data source

Post by scottb »

Hi everyone,
I'm trying to find the right way to do this and I'm sure it's simple. I have a form (frmDonationsSummary) that contains two text boxes (FiscalYTD and CalendarYTD). The row source for each is qryFiscalYTD and qryCalendarYTD. If I leave this form to go to another and update data, then close the form and return to frmDonationSummary (which remains open) the text boxes do not update. F5 solves the problem but I'm trying to use requery to solve this.
Should I use On Active or After Update and for that matter Refresh or Requery? Been playing with this for a while but can't get it to work.
Any help would be greatly appreciated.
Thanks! - Scott

User avatar
HansV
Administrator
Posts: 78455
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Requery a form with text boxes as queries as data source

Post by HansV »

A text box has a Control Source, which must be a field in the form's Record Source or an expression (formula). It does not have a Row Source.
Best wishes,
Hans

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Requery a form with text boxes as queries as data source

Post by scottb »

Sorry it is a list box. I thought it was created at a text box. My mistake. Thanks Hans.

User avatar
HansV
Administrator
Posts: 78455
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Requery a form with text boxes as queries as data source

Post by HansV »

Try the On Got Focus event of frmDonationSummary:

Code: Select all

Private Sub Form_GotFocus()
    Me.FiscalYTD.Requery
    Me.CalendarYTD.Requery
End Sub
Best wishes,
Hans

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Requery a form with text boxes as queries as data source

Post by scottb »

Thank for the quick response. That didn't work.

User avatar
HansV
Administrator
Posts: 78455
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Requery a form with text boxes as queries as data source

Post by HansV »

Does it work if you use the On Activate event of frmDonationSummary instead of the On Got Focus event?
Best wishes,
Hans

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Requery a form with text boxes as queries as data source

Post by scottb »

That did it. Thank you very much Hans. Have a great week.