?
Solved

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

Posted on 2014-10-15
13
Medium Priority
?
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 58
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 38

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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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
 
LVL 38

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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

762 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