Set date according to field in a form!

N

Niklas Östergren

Hi!

I´d like to set a date depending on what´s selected in a QBF-form (Query By
Form).

If the user selects to display all members which had membership for year
2003 and which was between 20 - 25 years old during year 2003. Then I have a
problem because i don´t know how to do? :)

The user select a membership year (calculated with
DateDiff('yyyy';[tblMemberShip].[DoB];Date()) ) from a combobox
(cboSelectMemberShipYear). And the user, in this case, type in 20 and 25 in
two textboxes (txtAgeFrom and txtAgeTo).

Now to my problem:
Everything works great but when I do the calculation of age I compare it
with today´s date instead of with the last date of the year that the user
have selected in cboSelectMemberShipYear, which in this case should bee
2003-12-31.

I have the value "2003" from cboSelectMemberShipYear but I don´t know how to
add the last date of the year to it!???

TIA!
// Niklas
 
K

Ken Snell

DateSerial(2003 + 1, 13, 0)

Above will give you the last day of the last month of the year 2003. So, in
your case,
DateSerial(cboSelectMemberShipYear + 1, 13, 0)
 
N

Niklas Östergren

Thank´s a lot Ken!

It was usefull!

// Niklas


Ken Snell said:
DateSerial(2003 + 1, 13, 0)

Above will give you the last day of the last month of the year 2003. So, in
your case,
DateSerial(cboSelectMemberShipYear + 1, 13, 0)


--
Ken Snell
<MS ACCESS MVP>


Niklas Östergren said:
Hi!

I´d like to set a date depending on what´s selected in a QBF-form (Query By
Form).

If the user selects to display all members which had membership for year
2003 and which was between 20 - 25 years old during year 2003. Then I
have
a
problem because i don´t know how to do? :)

The user select a membership year (calculated with
DateDiff('yyyy';[tblMemberShip].[DoB];Date()) ) from a combobox
(cboSelectMemberShipYear). And the user, in this case, type in 20 and 25 in
two textboxes (txtAgeFrom and txtAgeTo).

Now to my problem:
Everything works great but when I do the calculation of age I compare it
with today´s date instead of with the last date of the year that the user
have selected in cboSelectMemberShipYear, which in this case should bee
2003-12-31.

I have the value "2003" from cboSelectMemberShipYear but I don´t know
how
to
add the last date of the year to it!???

TIA!
// Niklas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top