Date Change issue (1 Viewer)

bk1010

Registered User.
Local time
Today, 06:56
Joined
Nov 16, 2009
Messages
16
Hi, this should be simple.
I have created a form with a From Date and a To Date, I have coded a filter that updates an attached subform.

However, when I change either date I need to press enter into order for the subform to update. I have tried events "On Click", "On Change" , "After Update", etc neither work.

I trying to get the subform update the subfrom when the date selected changes?

Thanks in advance
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:56
Joined
Oct 29, 2018
Messages
21,493
Hi. The OnChange event should work. How exactly were you updating/changing the date?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:56
Joined
May 7, 2009
Messages
19,247
where and what is your code to update the subform?
use the [From date] and [To date] textboxes AfterUpdate Event.
 

bk1010

Registered User.
Local time
Today, 06:56
Joined
Nov 16, 2009
Messages
16
Hi both, thanks for the reply.

The [FromDate] and [ToDate] are textboxes, where the user can just choose a date. It then runs a call function that requeries the subform.

Private Function TaskTypeSearch()
Forms("frm_Reporting_AllTasks")("frm_AllTasks_Subform").Requery
End Function
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:56
Joined
May 7, 2009
Messages
19,247
make the function Public:
Code:
Public Function TaskTypeSearch()
Forms("frm_Reporting_AllTasks")("frm_AllTasks_Subf orm").Requery
End Function

[FromDate]->Property->Event
After Update: =TaskTypeSearch()


[ToDate]->Property->Event
After Update: =TaskTypeSearch()
 

bk1010

Registered User.
Local time
Today, 06:56
Joined
Nov 16, 2009
Messages
16
Thanks arnelgp,

The code has worked, however I'm trying to get the subform to update without the user pressing enter. Is there anyway to achieve that? I've tried On Change event but no luck
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:56
Joined
May 7, 2009
Messages
19,247
OnChange will fire.
but the problem is that the Value of the textbox is the same.
what has changed on the textbox is its Text property.
so if your query is based on the form's control, it will not filter by the textbox Text property.
you need to modify the Criteria and use Tempvars.
you passed the Text of the textbox to Tempvars.
and requery the subform.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:56
Joined
Oct 29, 2018
Messages
21,493
Thanks arnelgp,

The code has worked, however I'm trying to get the subform to update without the user pressing enter. Is there anyway to achieve that? I've tried On Change event but no luck
Hi. I agree with Arnel. If you want to use the Change event, you'll have to commit the date change first before requerying the subform. The way I might do it is to update the subform's Record Source rather than simply using Requery.
 

Users who are viewing this thread

Top Bottom