Autofill Associated Data

unclefink

Registered User.
Local time
Today, 12:36
Joined
May 7, 2012
Messages
184
I have an unbound form that a user will fill in a start date; end date; and "week number" to generate criteria for unrelated queries to run a report.

Currently, I have the Start Date as the user entering the desired date and then then "end date" autofilling upon entering 6 days later than the start date.

So far so good.

What I am trying to do now, is have the "Weeknumber" textbox autofill the week number based on the date generated in the "EndDate".

For Example: EndDate=1/12/2013
Week Number: Autofills=2 indicating the second week of the year.

None of these text fields are generating a table and are solely used for query criteria.

Thanks in advance, much appreciated.
 
What you need is DatePart(), the first argument to the function is interval, since you wish to get the Week Number, use WW.. Something like..
Code:
DatePart("WW",Date) 
[COLOR=Green]'the above would return 3[/COLOR]
 
What you need is DatePart(), the first argument to the function is interval, since you wish to get the Week Number, use WW.. Something like..
Code:
DatePart("WW",Date) 
[COLOR=green]'the above would return 3[/COLOR]

As mentioned above this form is an unbound so everything is set within itself. Where should I put this code. I placed it in the default value of the week number but its throwing an error: Runtime Error 13 "type mismatch"
 
Put that in the Control Source.. As
Code:
=DatePart("WW",Date)
 
I've attached a copy of the form i am working on to illistrate my issue.
 

Attachments

Perfect, I was overanalyzing it and adding too much. Thank you very much for the help. Much appreciated.
 
Unfortunately I do not have Access on my home computer, I will look into it tomorrow.. I hope someone will be able to give you a solution before that.. In the mean time look into post 4..

Okay seems you have found the solution.. Glad to hear.. :) Good luck..
 
Last edited:

Users who are viewing this thread

Back
Top Bottom