Identifying row in Calendar Control

M

Mark A. Sam

Hello,

Does anyone know how to identify the row of a selected date in a Calendar
control? I thought I could do it by identifying the date of the Sunday of
the week where the first day of the month resides, but that could be on Row
2 of the Calendar as in June 2008. In that month the first row of the
calendar displays May 25-31 a 7 day span. Then Jun 1 displays on row 2. If
June 1 (and other months) displayed on Cell (1,1) of the calendar, I would
have this solved. Does that make sense?

Thank you for any help and God Bless,

Mark A. Sam
 
L

Linq Adams via AccessMonster.com

The question in and of itself doesn't really make a lot of sense. If we knew
exactly what you were trying to accomplish perhaps we could help.
 
L

Linq Adams via AccessMonster.com

Sorry, cat jogged my hand and I clicked on "send" too soon! The problem with
this kind of hack is that different calendars display differently. Some
***always*** display 6 rows, filling in "non-current month" boxes with dates
from previous/next months. Others show only the number of rows neccessary to
display the month. June 08 would require 5 rows; February 09 would require a
mere 4 rows.

So this wold have to be specific to the given calendar's way of displaying.
I'll work on a hack when I get time, b ut I need to know how your calendar
handles this. When you set this calendar to February 2009, how any rows does
it display?
 
M

Mark A. Sam

Hello Linq, A report I am working on is representeed by full weeks, from
Sunday to Saturday. A Calendar control has 6 rows. I have option six
buttons with arrows each pointing to a particular row. I want the user to
click a button to select the week that he wants for the report, rather than
clicking on the calendar. So if the user clicks a button corresponding to a
row I want to be able to extract the date for Sunday and Saturday of that
row.

Sun Mon Tue Wed Thu Fri Sat

--> 25 26 27 28 29 30 31 May
--> 1 2 3 4 5 6 7 June
--> 8 9 10 11 12 13 14
-->
-->
-->
 
M

Mark A. Sam

Linq Adams via AccessMonster.com said:
Sorry, cat jogged my hand and I clicked on "send" too soon! The problem
with
this kind of hack is that different calendars display differently. Some
***always*** display 6 rows, filling in "non-current month" boxes with
dates
from previous/next months. Others show only the number of rows neccessary
to
display the month. June 08 would require 5 rows; February 09 would require
a
mere 4 rows.

So this wold have to be specific to the given calendar's way of
displaying.
I'll work on a hack when I get time, b ut I need to know how your calendar
handles this. When you set this calendar to February 2009, how any rows
does
it display?

Sorry, I didn't see this post previously.

6 Rows. It doesn't seem to change. It is always 6 rows. This is Calendar
control 10 means anything.
 
B

Bob Quintal

Hi Mark,

I know it's a workaround but you can calculate the start and end
dates for any week from any date in that week.

The weekday() function returns a number from 1 to 7. Check the help
to see how to define the first day e.g. sunday by default, or
tuesday)

The dateadd() function returns a date n calendar intervals away from
a given date.

So dateadd("d", 7-weekday(DateSelected),Dateselected,vbSunday) will
return June 7, 2008 for any of the days in the second row of the
calendar you posted. calendar

To get the first day of the week subtact 6 from the seven.

Q
 
M

Mark A. Sam

Bob, thanks for the reply, but I know how to get the starting and ending
week dates. I know how to get the date for the first day of the month. The
problem is that the first day of the month isn't necesarily on position one
of the calaendar control, meaning Row 1 Column1. That is what I need to
determine in order to know which button is being referenced when it is
clicked.
 
B

Bob Quintal

Bob, thanks for the reply, but I know how to get the starting and
ending week dates. I know how to get the date for the first day
of the month. The problem is that the first day of the month
isn't necesarily on position one of the calaendar control, meaning
Row 1 Column1. That is what I need to determine in order to know
which button is being referenced when it is clicked.

I don't know what calendar you use, but presume the dates must be
displayed in some textbox or label. you could then test for the
value of a textbox on the same row as the button.

The option was to not put separate buttons on the calendar, but let
the users click on any date, and then convert the date to the week.

Otherwise find another calendar,
 
M

Mark A. Sam

I don't know what calendar you use, but presume the dates must be
displayed in some textbox or label. you could then test for the
value of a textbox on the same row as the button.

I use the Microsoft Calendar 10.0
If I could test for the row the button was on, this would be solved, becuase
that is my objective. I can't seem to do that, but can determine the weekday
of the first day of the month and figure out the Sunday of that week. If
that was always position 1,1 of the grid, I could count to the row I need,
but that isn't the case.
The option was to not put separate buttons on the calendar, but let
the users click on any date, and then convert the date to the week.

I already can do that. It may be confusing to a user, and even to me a year
later when I have forgotten what I have done. I am using the buttons to
avoid confusion as to what is happening.
Otherwise find another calendar,

Do you have a recommendation?
 
B

Bob Quintal

I use the Microsoft Calendar 10.0
If I could test for the row the button was on, this would be
solved, becuase that is my objective. I can't seem to do that, but
can determine the weekday of the first day of the month and figure
out the Sunday of that week. If that was always position 1,1 of
the grid, I could count to the row I need, but that isn't the
case.


I already can do that. It may be confusing to a user, and even to
me a year later when I have forgotten what I have done. I am
using the buttons to avoid confusion as to what is happening.


Do you have a recommendation?
datepicker by Brendan Kidwell evailable at
http://www.glump.net/content/accessdatepicker/

uses only Access, no add-ins, no .ocx, no references. Sweet.
You could even adapt it to show the 4,5, or 6 buttons captioned
"Week of mm/dd/yy to mm/dd.yy"
 
M

Mark A. Sam

Thanks Mike. The Datepicker Bob recommended will work fine. Becuase it is
an Access form, I can do what I initially wanted which is to show a week of
buttons as being clicked.
 

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

Top