Problem with Dateserial

B

Box666

I have a form open and I want to use the date from it in an expression
on a report that will open shortly - the form will still be open.(where
the form is called "RepInfo" and the date is "Lstupdt" in the format of
dd/mm/yyyy)
In plain english I want to say if the form date is the same month as
todays date then show message 1, if not show message 2. I have tried
various option but I cannot seem to hit the right combination.(I seem
to be having problems with my "," and ")" - amongst other things)
Assistance greatly received..

=Iif
(dateserial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstupdt])=dateserial(Year(date()),month(date()),"Reports
Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet
updated this month")
 
R

Rick Brandt

Box666 said:
I have a form open and I want to use the date from it in an expression
on a report that will open shortly - the form will still be
open.(where the form is called "RepInfo" and the date is "Lstupdt" in
the format of dd/mm/yyyy)
In plain english I want to say if the form date is the same month as
todays date then show message 1, if not show message 2. I have tried
various option but I cannot seem to hit the right combination.(I seem
to be having problems with my "," and ")" - amongst other things)
Assistance greatly received..

=Iif
(dateserial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstupdt])=dateserial(Year(date()),month(date()),"Reports
Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet
updated this month")

DateSerial requires three arguments and you are only supplying two?
 
B

Box666

I thought if I wanted to "match" 2 dates by month, then I only neede to
list the year and month, but if I included the day as well then I will
never get a match (apart fron the day the form is updated)
So do I need to list it as

=Iif
(dateserial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstu­pdt],day([forms]![RepInfo]![Lstu­pdt]))=dateserial(Year(date()),month(date()),day(date())),"Reports
Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet
updated this month")
 
R

Rick Brandt

Box666 said:
I thought if I wanted to "match" 2 dates by month, then I only neede
to
list the year and month, but if I included the day as well then I will
never get a match (apart fron the day the form is updated)
So do I need to list it as

=Iif
(dateserial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstu­pdt],day([forms]![RepInfo]![Lstu­pdt]))=dateserial(Year(date()),month(date()),day(date())),"Reports
Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet
updated this month")

Just use the number 1 for both DateSerial() calls as the final argument. Then
they will always match on the day.
 
B

Box666

Thank you, that just leaves me with the issue of what error I have in
the expression itself .. I think I may have the ")" or "," in the wrong
places

=Iif
(dateserial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstu­­pdt],1)=dateserial(Year(date()),month(date­()),1),"Reports

Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet
updated this month")
 
D

Duane Hookom

You were missing a ")" prior to the first ",1)":

=IIf(DateSerial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstu­­pdt]),1)=dateserial(Year(date()),month(date­()),1),"Reports
Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet updated
this month")


--
Duane Hookom
MS Access MVP
--

Thank you, that just leaves me with the issue of what error I have in
the expression itself .. I think I may have the ")" or "," in the wrong
places

=Iif
(dateserial(Year([forms]![RepInfo]![Lstupdt]),month([forms]![RepInfo]![Lstu­­pdt],1)=dateserial(Year(date()),month(date­()),1),"Reports

Last Updated "&[forms]![RepInfo]![Lstupdt],"CARE Reports NOT yet
updated this month")
 

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

Similar Threads


Top