calendar

109bow

Registered User.
Local time
Today, 21:25
Joined
Oct 24, 2007
Messages
141
I don't know if this is possible, but here goes.
I have a text box on a form that requires a date to be entered. I'm using Access 2013, so it provides a calendar to select the date required. I need the date to always be a Sunday, is there any way of getting the calendar to show only Sundays or is there another option to provide what I'm after?
Thanks in advance.
 
afraid not with the calendar control, but you can have code to check whether the day is a sunday and if not change it to the nearest sunday, sunday before or after as required.

Alternatively, create a combobox to list the sundays that the user chooses from
 
MS Access has functions for WeekdayName, WeekDay and Date.

Which Sunday should be entered? Is there a pattern?
 
Every Sunday would be entered, I have tried creating a table, to base a combo box on, with dates for consecutive sundays, but this seems a long way round to enter every sunday date. I wouldn't know where to start the create some kind of code that would do it for me.
 
I don't suppose there a way of listing the next 10 sundays, in a table or query, from DATE() so one could be selected from a combo box?
 
I think I need to clarify what I'm trying to achieve.
On the form a Sunday in entered in to a text box. This date is then used in 7 employee sign in sheets for the week, with each sheet adding a 1 to the date to give a date for each day. I may need to print out a number of weeks sign in sheets in advance, hence needing a number of dates for sundays.
 
jdraw, thanks for your reply. I'm sure this is along the lines of what I'm after. However, I'm not sure where to put this code, do I need to change the text box to a combo and the enter the code under the build event tab? you may have guessed I'm not that competent with VB!
 
I would have thought you could just base it on today

LastSunday=date()-weekday(date())+1
NextSunday=date()-weekday(date())+8
 
for the next 10 sundays, set your combo rowsource type to value list then in the form open event put the following code


Code:
dim I as integer
cboSundays.rowsource=""
for I=1 to 10
    cboSundays.rowsource=cboSundays.rowsource & date()-weekday(date())+1+(I*7) & ";"
next i
 
Thanks CL_London,
I have done exactly as you instructed in your post. However I get a runtime error "424" object required. The code debugger shows;
cboSundays.RowSource = "" as requiring something.
As I'm useless with code, can you suggest what I'm missing
many thanks for your patience!
 
CJ_London, I think I'm making progress, but not quite there. I have renamed the combobox cboSundays and the code now runs to give the sundays date, however it only returns 5 dates, and they are every other sunday date.
Any ideas?
Thanks
 
sounds like the code you are using is stepping by 2.

copy and paste the actual code you are using
 
this is the code

Private Sub Form_Open(Cancel As Integer)
Dim I As Integer
cboSundays.RowSource = ""
For I = 1 To 10
cboSundays.RowSource = cboSundays.RowSource & Date - Weekday(Date) + 1 + (I * 7) & ";"
Next I
End Sub
 
in that case I think you have the combo columncount set to 2 - and check that columnswidths is blank and bound column is 1
 
CJ_London
That has solved the problem, many thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom