[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

Access Form Control Source coding for Date field

I have a daily down load of data that I do year around. This data does not need to include multiple years. So, every January this data search includes records from the previous year, which I do not need to carry over. I'd like it to only download the current year. However, the problem is that the source website will only allow me to download 1000 records maximum. Currently, there are about 500 records permonth so I just can't leave the control source set to 1-1-Current year.

Currenlty I am using
=DateSerial(Year(Date()),Month(Date()),Day(Date()))-90 (This is always 90 days less than "today's date")

However, I would like to change this.

I need the date to be January 1, Current Year. (1-1-2015) until 90 days of the current year have expired. Then I need it to be 90 days less than the current date. So every year it changes automatically with the calendar and will not include records from the previous year.
0
ggodwin
Asked:
ggodwin
  • 2
  • 2
1 Solution
 
als315Commented:
You can use this code for your field:
=IIf(CDate("1/1/" & Year(Now()))>DateAdd("d",-90,Now()),CDate("1/1/" & Year(Now())),DateAdd("d",-90,Now()))

Open in new window

0
 
ggodwinAuthor Commented:
Where does that code get entered at?
0
 
als315Commented:
You can enter it to your field on a form, replacing your code:
=DateSerial(Year(Date()),Month(Date()),Day(Date()))-90
0
 
ggodwinAuthor Commented:
Worked perfectly
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now