Data range in a box determines filter of a subform (1 Viewer)

AccOUCH

Registered User.
Local time
Today, 14:20
Joined
Sep 27, 2018
Messages
25
Hello!

I have a form (A) that contains a subform (B). Now, the B shows registers from a query that is defined with an SQL. I would like to make this SQL change on order to contrain the dates of the registers shown.

In other words: Now the subform (B) shows registers from dates fixed in its SQL definition. But I would like to change that definition depending on the year an user wants to type down o a text box in the main form.

How to change that sql in the subform in order to achieve that result. I found no way to do it at present.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:20
Joined
Oct 29, 2018
Messages
21,358
Hi. Have you tried using a parameter query? For example:
Code:
SELECT * FROM TableName WHERE DateField Between Forms!FormName.StartDate And Forms!FormName.EndDate
 

AccOUCH

Registered User.
Local time
Today, 14:20
Joined
Sep 27, 2018
Messages
25
Hi! But Can I put that parameter query in a subform? Or within a button to change the SQL of the subform?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:20
Joined
Oct 29, 2018
Messages
21,358
Hi! But Can I put that parameter query in a subform? Or within a button to change the SQL of the subform?
Yes, you can. Just make sure the form you're referring to with the parameter is open when you open the form or the query using those references.
 

Users who are viewing this thread

Top Bottom