Calendar Dates

thekid618

New member
Local time
Today, 13:53
Joined
Mar 28, 2011
Messages
5
I have imported a calendar from within vba into two comboboxes. These combo boxes will hold different dates once selected from the calendar. I want the user to only select dates on the calendar that fall on a sunday and a saturday. Is there a way i can get the calendar to recognize and prompt the user if a Monday through Friday was selected?
 
You can use the WeekDay() to test for the day of the week selected
 
For some reason i still cant get the calendar to recognize the day. Heres a snippet of what i have put into one of my combo boxes that hold a date.If cboStartDate = WeekdayName(3, True, vbTuesday) Then intResponse = MsgBox("This is Not a sunday", vbYesNo)
 
Would it not be easier to build a Query on the dates, and add an expression to get the day of the week, and then base the Combo box on that query? You could then use the weekdays to accept as criteria.

For example:
-Query contains the dates to check in field "date"
-Add a new field to the end of the query:
Day: Weekday([date])
-Enter the criteria for Day to 6 or 7.

That query will now only show results from whatever source the dates come from, which fall on a saturday or sunday. Building a combo box on that query will allow you to only allow them to select weekend dates by only showing them.
 
Would it not be easier to build a Query on the dates, and add an expression to get the day of the week, and then base the Combo box on that query? You could then use the weekdays to accept as criteria.

For example:
-Query contains the dates to check in field "date"
-Add a new field to the end of the query:
Day: Weekday([date])
-Enter the criteria for Day to 6 or 7.

That query will now only show results from whatever source the dates come from, which fall on a saturday or sunday. Building a combo box on that query will allow you to only allow them to select weekend dates by only showing them.

When you say build a query on the dates, are you referring to set dates? Because these dates will change on a weekly basis. Will this format you suggested work easier with that scenario?
 
If you add a column to a query based on an expression, that will be added to each record. Don't refer to set dates, just the [date] value in the query. Have you ever built calculations or expressions in a query using the expression builder?
 
to be honest i havent. But i plan to take a stab at this approach. ill post up the results.
 
The attached image should help you get started with how to get the new column. It literally just acts like a new column in the query and can have criteria applied to it (this will let you limit your combo box to saturdays and sundays only).
 

Attachments

  • build access.JPG
    build access.JPG
    35.9 KB · Views: 121
i appreciate the picture, im going to try and implement this. By building this query and using expressions, is the use of the calendar even necessary anymore?
 
Not really. You just need to have a Date column you can query. I imagine it'd be more versatile without the calendar, so you can just put any date into the table. A calendar input could be useful for a data entry form for the table though, although I wouldn't know a lot about that idea.
 

Users who are viewing this thread

Back
Top Bottom