Whereclause to return specified age range

josephbupe

Registered User.
Local time
Tomorrow, 01:06
Joined
Jan 31, 2008
Messages
247
Hi,

I have two text boxes (txtAgeFrom and txtAgeTo). In the subform age is calculated and displayed in a text box (txtAge) but is not stored anywhere. I want the whereclause I could use to return persons whose age fall within the range specified in the two text boxes (txtAgeFrom and txtAgeTo) in form.

I will appreciate.

Joseph
 
Put something like this in the criteria:
Code:
[Datefield] Between [Forms]![NameOfForm]![txtAgeFrom] AND [Forms]![NameOfForm]![txtAgeTo]
 
Put something like this in the criteria:
Code:
[Datefield] Between [Forms]![NameOfForm]![txtAgeFrom] AND [Forms]![NameOfForm]![txtAgeTo]


Hi,

Please, the search form where I have txtAgeFrom and txtAgeTo is unbound. All other queries am running from this form are activated on click of a command button, and query results show up in another popup, which is bound to the query.

I was hoping to do it in vb code behind the command button. Am sure you the right person to help, going by your member name.

Joseph
 
Please, the search form where I have txtAgeFrom and txtAgeTo is unbound. All other queries am running from this form are activated on click of a command button, and query results show up in another popup, which is bound to the query.
All you need to do is put that criteria in the other queries, not the search form. It would be wise to validate those two textbox entries to ensure that they are valid dates using the IsDate() function. Here's a link on the BETWEEN clause too (in case you need it):

http://techonthenet.com/sql/between.php

I was hoping to do it in vb code behind the command button. Am sure you the right person to help, going by your member name.

Joseph
You don't need vb as already indicated and you will be pleased to know that there are other capable members on here that could help you too ;)
 
All you need to do is put that criteria in the other queries, not the search form. It would be wise to validate those two textbox entries to ensure that they are valid dates using the IsDate() function. Here's a link on the BETWEEN clause too (in case you need it):

http://techonthenet.com/sql/between.php

You don't need vb as already indicated and you will be pleased to know that there are other capable members on here that could help you too ;)


Hi,

My other option was to change the line
Code:
.        Else 'Both start and end dates present.
TO
Code:
.        ElseIf IsDate(Me.txtStartDate) and isDate(me.txtEndDate) THEN 'Both start and end dates present.
It worked exactly the way I wanted.

Thank you again for your help.

Joseph
 

Users who are viewing this thread

Back
Top Bottom