Trying to use Year as a variable

  • Thread starter Thread starter Anthony Viscomi
  • Start date Start date
A

Anthony Viscomi

I am creating an Update Query that will filter by 2 dates using a Between
Statement. I have the Month & Days "hard coded" in as the criteria, but I
want the Year to be read in from an active form that contains the "year"
fiield. I thought that it should look like this:
Between 01/01 Forms![frmYear_Selector]![Combo0] and 01/31/
Forms![frmYear_Selector]![Combo0]

but that doesn't work.

Can someone please help?
Thanks
Anthony
 
Much safer is

Between DateSerial(Forms![frmYear_Selector]![Combo0], 1, 1) and
DateSerial(Forms![frmYear_Selector]![Combo0], 1, 31)
 
Anthony said:
I am creating an Update Query that will filter by 2 dates using a Between
Statement. I have the Month & Days "hard coded" in as the criteria, but I
want the Year to be read in from an active form that contains the "year"
fiield. I thought that it should look like this:
Between 01/01 Forms![frmYear_Selector]![Combo0] and 01/31/
Forms![frmYear_Selector]![Combo0]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Should be:

Between CDate("01/01" & Forms![frmYear_Selector]![Combo0]) and
CDate("01/31/" & Forms![frmYear_Selector]![Combo0])

You have to turn a string into a date. Using CDate() (convert to
date) accomplishes that....assuming that the Combo0 returns a valid
integer year value.

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQFY9AYechKqOuFEgEQJllgCff6YXOzRw8iS0/f0g+BWisuuqX5QAnj6e
pMV6bhOFwiBjr9KzDG9++0/3
=fGNi
-----END PGP SIGNATURE-----
--
 
Thanks Doug! I had a "brain freeze" I guess.
Douglas J. Steele said:
Much safer is

Between DateSerial(Forms![frmYear_Selector]![Combo0], 1, 1) and
DateSerial(Forms![frmYear_Selector]![Combo0], 1, 31)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Anthony Viscomi said:
I am creating an Update Query that will filter by 2 dates using a Between
Statement. I have the Month & Days "hard coded" in as the criteria, but I
want the Year to be read in from an active form that contains the "year"
fiield. I thought that it should look like this:
Between 01/01 Forms![frmYear_Selector]![Combo0] and 01/31/
Forms![frmYear_Selector]![Combo0]

but that doesn't work.

Can someone please help?
Thanks
Anthony
 
Back
Top