473,498 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dates for the week populate on form when "Week of" date is chosen from drop-down.

3 New Member
I am trying to create a form with a drop down box that lets you choose the "Week of" and when chosen it will automatically populate the dates for the week on the form so that users can populate productivity for each day. I'm Intermediate but have been having trouble figuring out how to do it. Can't really find any step by steps to help. P.S. Access 2007. Thank you
Oct 18 '13 #1
3 2286
ADezii
8,834 Recognized Expert Expert
I am a little confused by your request, but I'll give it a stab.
  1. Assuming that Week Of refers to a Monday, the following Code will populate a Combo Box named cboWeekOf with the Dates representing all Mondays between the Current Date and end of the year.
    Expand|Select|Wrap|Line Numbers
    1. Dim dteCtr As Date
    2. Dim strBuild
    3. Dim cbo As Access.ComboBox
    4.  
    5. Set cbo = Me![cboWeekOf]
    6.  
    7. cbo.RowSourceType = "Value List"    'Critical
    8.  
    9. For dteCtr = Date To DateSerial(Year(Date), 12, 31)
    10.   If Weekday(dteCtr) = 2 Then    'a Monday
    11.     strBuild = strBuild & CStr(dteCtr) & ","
    12.   End If
    13. Next
    14.  
    15. strBuild = Left$(strBuild, Len(strBuild) - 1)  'Remove Trailing ','
    16.  
    17. cbo.RowSource = strBuild
  2. After a Week Of Date is selected in the Combo Box (cboWeekOf), the following Code will populate seven Text Boxes named Text1...Text7 with the Dates of that selected Week.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cboWeekOf_AfterUpdate()
    2. Dim intDteCtr
    3.  
    4. If IsNull(Me![cboWeekOf]) Then Exit Sub
    5.  
    6. For intDteCtr = 0 To 6      'Days of the Week
    7.   Me.Controls("Text" & CStr(intDteCtr + 1)) = DateAdd("d", intDteCtr, CDate(Me![cboWeekOf]))
    8. Next
    9. End Sub
Oct 20 '13 #2
jaeprov7
3 New Member
Something like this form that I found on the website below

http://stackoverflow.com/questions/7...7-with-weekday

Thank you I will try your code and see how it goes. Thanks again
Oct 24 '13 #3
jaeprov7
3 New Member
Where is says "value list" do I need to create a table with all of the dates in order for this to work?
Oct 24 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
9980
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
3
2057
by: Deano | last post by:
Here's a good one that keeps defeating me... I have a continuous form that has a date textbox as one of the controls. The user can choose any date they like including one they have already...
10
2222
by: RoadRunner | last post by:
Hi, I have a employee vacation database that has a vacation table that has the employee name, pay week and date of vacation. I have another lookup table with pay week code and date range for the...
10
2797
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
13
1959
by: PW | last post by:
Hi, This is bizarre. I've check and rechecked the spelling, cut and paste the name of the form (when trying to rename the form) and the control yet I still get a parameter prompt when the form...
2
2893
by: Blackmore | last post by:
I am trying to use javascript to calculate the difference between two form inputted dates and return the result to another form object. When I load up the page with the function on my web browser...
21
2030
by: bha123 | last post by:
Hi I am struck with this problem . i have 2 forms .. Form A has 2 dropdown box state : city :
14
1696
by: stateemk | last post by:
I have a form with multiple controls on it. I would like to be able to have the date automatically recorded on the form when any changes have been made to show when the record was last updated. Is...
3
2829
by: Daved Nconfused | last post by:
I found this code and would like to make it so that if a person is checking availability for something, when the correct date is selected, it goes to a URL. Example, click DEC. 18 2010 and it goes...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.