Solved

Access: force a user to choose a friday from the calendar?

Posted on 2014-10-15
13
135 Views
Last Modified: 2014-10-17
On one of my Access forms I have a field that the user can add a date to. It formatted to 'date'  so the little calendar appears when they click on it and they chose the date from there.

Is there a way to limit their choice to a Friday?
0
Comment
Question by:Megin
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40383127
I think you cannot do that but you can set a control afterwards to check is the friday selected:


If Weekday(Me.DatePicker) <> 5 Then
  MsgBox "You Can Select only Friday!"
Else
  Me.DateTextBox = Me.DatePicker
End If

Open in new window

0
 
LVL 57
ID: 40383979
As samo4fun indicated, you can't modify the calendar that I'm aware of, but you can check if the weekday for a date is a friday in the controls beforeupdate event.

Do:

Cancel = True

 if an error occurs.   This will stop the control from accepting the value

Jim.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40384571
Friday is day 5 of the week if it starts on Monday.  It is day 6 if the week starts on Sunday.  In the US we generally use Monday as the start of the week but you can override that if necessary.
0
 
LVL 24

Expert Comment

by:Bitsqueezer
ID: 40387558
Hi,

normally the user should know that he should only choose a Friday, i.e. through a hint on the form or anything else like that.
So the more userfriendly method would be to check the chosen date after input and programmatically change the date to the Friday date of the same week. On this way the user can click on any date in a week and automatically gets the Friday date which is better than choosing a date and annoy him with a message box which says "hehehe...silly user, you have again chosen the wrong day, try it again and if you do not choose a Friday I will come back to laugh at you again!"
As said above, the user should already know to choose a Friday so he will not be surprised that the date changes to the Friday date of the same week, he will instead love the comfort.

Cheers,

Christian
0
 

Author Comment

by:Megin
ID: 40387573
samo4fun: That looks great, but I can't use Me.DatePicker. DatePicker is not available to me.

Bitsqueezer: That would be fantastic, but I have no idea where to start with that. Can you help me out further?
0
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40387575
You need to download it and register it to your system..

Download here : http://www.microsoft.com/en-us/download/details.aspx?id=10019

then use this steps to register it http://support.microsoft.com/kb/249873

Than you will be able to use it
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 34

Expert Comment

by:PatHartman
ID: 40387581
The date picker has been integrated since A2007.  It is automatically activated for any control bound to a field with a date data type.  To make an unbound control a "date",  you need to specify a date format for the control.
0
 

Author Comment

by:Megin
ID: 40387588
Sorry. I don't think I was clear.

The actual datepicker attached to the field works fine.
The problem is using it in the VBA code. It is not a method/data member that is available to me.
0
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 40387589
maybe it is Me.DatePicker1?
0
 

Author Comment

by:Megin
ID: 40387590
And I can't download it. I am on a network and am not an administrator. Downloading it requires administrator rights/
0
 

Author Comment

by:Megin
ID: 40387591
When I type in "Me.", nothing beginning with the word "Date" shows up.
0
 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 500 total points
ID: 40387695
Hi,

as you already said in your initial post you already have a date picker so I guess you have at least A2007. So you don't need to download anything here.

The date picker itself cannot be programmed, it is automatically activated if the field is of date type and you didn't explicitly deactivated it.

But that's not needed, let the user simply choose a date of the week he want and then use i.e. the AfterUpdate event of the textbox to change the date to the Friday date.

If your textbox has the name "MyDate" it would be as simple as that:
Private Sub MyDate_AfterUpdate()
    Me.NyDate = DateAdd("d", 5 - Weekday(Me.MyDate, vbMonday), Me.MyDate)
End Sub

Open in new window


Cheers,

Christian
0
 

Author Closing Comment

by:Megin
ID: 40387704
That is perfect!!!!!

Just what I needed. Thank you!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now