473,545 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Validation

28 New Member
Ok, so my other little problem. I can't seem to get a working validation on the BookingDate field of frmBookings. I've tried everything immaginable and even though a lot of them worked they also came up with extra message boxes which I hadn't set. So not quite sure what to do with that. Any ideas?

** Edit **
This new question was split from Time Interval Overlapping (MS Access 2003).
Apr 20 '11 #1
8 1540
NeoPa
32,563 Recognized Expert Moderator MVP
Zac, I'm sorry but this new question is also very short of the necessary information for us to help. You'd need to give details of what you're trying to do and what you've tried already etc. It needs quite a bit of work to be a proper question.
Apr 20 '11 #2
Zac Harvey
28 New Member
Well the reason for that Is that I supplied my datbase in the previous thread and therefore thought it would be easier for someone to just look at that rather than me posting the code etc. But nevermind, I will do that now. Makes sense since you've moved it to a new thread anyway.
Apr 21 '11 #3
Zac Harvey
28 New Member
On my booking form I have a field which records the date for which a room is being booked and it is a mandatory field. I simply wanted to ensure that the user could not enter a date which preceeded the date on which it was being entered i.e. Date()

Now one thing to point out is that whenever I try and include Date() in an If function it removes the brackets then when it checks it says it cannot find the date field. So I've tried putting the statement within other brackets both rounded and squared.

But other that that I have tried using various Macros and expressions in the validation box of 'BookingDate' on both the form and the table itself. (One thing I'd like to clarify here.. am I right to assume that the validation should be done on the form and not in thet table as then whenever the date of that particular booking passed it would become invalid and possibly cause problems?)

Anyway, I've tried doing it so many different ways I cant remember but heres one of the basic ones I tried which wont work because of the Date() problem described above.

Expand|Select|Wrap|Line Numbers
  1. Private Sub BookingDate_BeforeUpdate(Cancel As Integer)
  2.     If Me.BookingDate > Date Then
  3.     MsgBox ("Please check your booking date. It can't preceed todays date.")
  4.     Me.BookingDate.Undo
  5.     End If
  6. End Sub
  7.  
Apr 21 '11 #4
NeoPa
32,563 Recognized Expert Moderator MVP
A few small issues to cover here. Let's start with the easiest.

It's always a good idea to post your question in text in the post rather than expect people to look through your database to determine what you need. It's a rule, but it benefits you just as much as it does the site. Consider how many of the experts are going to go to the trouble of downloading your database and having a look through it (which may be more complicated than it sounds as they wouldn't necessarily know where to start), just to determine what the question should be? I'm not trying to sound critical here, as the interaction we've already shared tells me that you're ready to learn new things when they're explained. I'm just trying to explain the situation so it's more easily understood why this rule is as it is. There are more reasons than just this (but I won't bore you with them).

Moving on again to the technical points :
  1. I've seen the editor remove the parentheses from after a function call before (particularly with Date()), but I've never seen it resolving to a field reference when ambiguous (IE. without it being written as [Date]). I may have to have a look in your database after all. Can you tell me where I can find this code? Which form is it associated with?
  2. Your line #4 uses Undo, whereas the Cancel parameter is set up specifically to do that job in a BeforeUpdate event procedure. Simply say :
    Expand|Select|Wrap|Line Numbers
    1. Cancel = True
  3. Other than that - I would certainly expect that code to work as you envision it.
Apr 22 '11 #5
Zac Harvey
28 New Member
Thanks for replying Neo, Hope you enjoyed the extended weekend. Sorry about the seperate posts above, I will bear this in mind in future posts.

I have taken your advice and changed the action to 'Cancel = True'.

The date function in question can be found under Forms > frmBookings if you still intended on taking a look.

Also I have realised another major problem with this date business. Because I usea pop-up callander to give the user the option select the date it proved a way around the validation. Are you aware of anything I can do about this?

Cheers
Apr 27 '11 #6
NeoPa
32,563 Recognized Expert Moderator MVP
I will try to look at this for you Zac. It's been pretty hectic the last few days I'm afraid (Good when you're self-employed as I am - but still a nuisance).
Apr 28 '11 #7
Zac Harvey
28 New Member
No problem, I get it. Much appreciated as always Neo.
Apr 28 '11 #8
NeoPa
32,563 Recognized Expert Moderator MVP
Zac, you're using the CalendarFor() procedure directly in the OnClick property of your CommandButton control. This isn't something I'm very familiar with, but it seems it updates the specified TextBox control without triggering any BeforeUpdate event of that control.

This seems a bit of an awkward approach to me (compared to using a Calendar Control 11.0 object for instance), but if you're set on that then I can only suggest creating a hidden (and unbound) TextBox and have the CommandButton's OnClick point to an event procedure that executes the CalendarFor() procedure then tests the results. Only if the selection is correctly validated would you copy the date to the control [BookingDate].
May 3 '11 #9

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

Similar topics

30
3643
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code seems unnecessarily long. For some while, the following approach has been given here :- function ValidDate(y, m, d) { // m = 0..11 ; y m d...
14
13243
by: Steve Wright | last post by:
I am trying to validate if an entry on a form is a date. I have adapted code I found here http://www.codingforums.com/archive/index.php/t-14325 as below but I can't seem the get the results that I am expecting. Can anyone help please TIA Steve PS I'm new to javascript
11
8111
by: Diego | last post by:
Hi all a quick question: how can I validate a date in asp.net (2.0) with c#? I didn't find a quick anwer. Thanks, Diego.
3
1569
by: LDD | last post by:
Are there any built in time and/or date validation methods that one can make use of in .NET? thanks folks LDD
3
8696
by: pmarisole | last post by:
The following javascript code gives me the date validation that I need except after the correct date is entered into the field, it puts the date in the wrong format EXAMPLE: User enters 2/14/2006 and it shows in the field Feb 14 2006 after the onBlur I want it to leave the formatting of the date in the field as 2/14/2006 and not change...
2
6732
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so I' using the leave event. Right now I am creating a 'leave' sub for each of the fields. However, I'd like to simplify that and just call the name...
1
1900
by: jsredhar | last post by:
Dear Experts, I have two text boxes in my form (f1) i'm prompting the users to select the date from callender which is embeded within the from. when the users Pick the date from the calender.it will be displayed as mm/dd/yyyy format. i'm getting the from date value at textbox (FromDate) and to date value at another textbox(ToDate). i've to...
8
1624
pradeepjain
by: pradeepjain | last post by:
<script language = "Javascript"> /** * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ // Declaring valid date character, minimum year and maximum year var dtCh= "/"; var minYear=1900; var maxYear=2100; function isInteger(s){
5
3426
Stang02GT
by: Stang02GT | last post by:
I have been asked to validate a date on our web-page so that people cannot enter dates like 14/1/08 or 2/30/06. I have found code that will do exactly what i need it to do, but i am not sure how to call it. It was suggested to be to have it run through an if statement and if the user enters an invalid date it will kick them to an error page. ...
2
11346
by: mshroom12 | last post by:
I am having trouble with the following project on hand. I use Eclipse to do my work in Java. This is what I'm supposed to complete. Date Validation In this exercise you will write a program that checks to see if a date entered by the user is a valid date in the second millenium. A skeleton of the program is in Dates.java. Open this program...
0
7675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7440
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.