473,388 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Access 2003: Date restrictions

23
Hi guys,

I have a couple of questions about date restrictions.
On one of my forms in my DB I have the MS calendar. The question I have is how do I prevent the user from selecting a date in past and from selecting no more than 45 days into the future. Example today is 12/08/06, I would like to prevent the user from selecting 12/07/06 and unable to select anything pass 01/22/06. Hope that makes sense.

Second part of my questions is I have another form which the source is from a table. In this table there is field which contains dates. The dates are appointments that are setup. On this form you are able to see the appointments from the past and those that are scheduled in the future. I would to restrict the form from showing appointments in the future. If the form is accessed today I would like for it to only show appointments for today and those in the past.
Any help or reference anyone can provide would be greatly appreciated.
Dec 8 '06 #1
3 2686
NeoPa
32,556 Expert Mod 16PB
I have a couple of questions about date restrictions.
On one of my forms in my DB I have the MS calendar. The question I have is how do I prevent the user from selecting a date in past and from selecting no more than 45 days into the future. Example today is 12/08/06, I would like to prevent the user from selecting 12/07/06 and unable to select anything pass 01/22/06. Hope that makes sense.
In the BeforeUpdate event of the control put in some code that checks the control is between today and today +45.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CtrlName_BeforeUpdate(Cancel As Integer
  2.     If Me.CtrlName < Date() _
  3.     Or Me.CtrlName > Date() + 45 Then
  4.         Call MsgBox("Invalid Date")
  5.         Cancel = True
  6.     End If
  7. End Sub)
Second part of my questions is I have another form which the source is from a table. In this table there is field which contains dates. The dates are appointments that are setup. On this form you are able to see the appointments from the past and those that are scheduled in the future. I would to restrict the form from showing appointments in the future. If the form is accessed today I would like for it to only show appointments for today and those in the past.
Any help or reference anyone can provide would be greatly appreciated.
Set record source of the form to
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM [table] WHERE [yourdatefield] <= Date()
Dec 8 '06 #2
JC21
23
Thank you NeoPa, it worked!
Dec 11 '06 #3
NeoPa
32,556 Expert Mod 16PB
Thank you NeoPa, it worked!
No Probs (Don't sound so surprised).
Dec 11 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: JustMe | last post by:
I don't know if this has anything to do with AccessXP running on Terminal Services with Access97/2000 also installed, but here is one example of a query that does not work any longer: SELECT...
4
by: JMCN | last post by:
object invalid or no longer set - confusion of the recordset in access 2003. i am currently converting from access 97 to access 2003. majority of the codes converted over perfectly fine, though...
35
by: deko | last post by:
Do I get more scalability if I split my database? The way I calculate things now, I'll be lucky to get 100,000 records in my Access 2003 mdb. Here some math: Max mdb/mde size = 2000 x 1024 =...
47
by: ship | last post by:
Hi We need some advice: We are thinking of upgrading our Access database from Access 2000 to Access 2004. How stable is MS Office 2003? (particularly Access 2003). We are just a small...
4
by: RM | last post by:
Had VS .Net 2002 installed on W2k Server SP3 and supported a number of web sites. Installed VS .Net 2003 on Friday and now all web sites using .Net & MS ACCESS get this strange error upon open. ...
5
by: Calvin X | last post by:
hi everyone, this may seem like a dumb question but here goes. I developed an asp.net app, works great, uploaded to production server and it works when tested from this server. But when I try to...
2
by: piyush1.mehta | last post by:
I am new to MS Access database and want to accomplish following. I have a database and report in MS Access 2003. There are multiple users who wants to access and generate their respective reports...
2
by: goodlie | last post by:
Hello; I have an access 2003 db on XP OS split with backend on sql2K. I want to put the front end on a fileserver for easier maintenance. I have 7 users using the database at any given time. ...
3
by: Sheldon | last post by:
I have the following query expression - Like Format((!!)) & "/*/" & (! !) which would translate to e.g. 04/*/2007 if someone is running a report for last month. The above expression is part of a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.