473,394 Members | 1,774 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,394 software developers and data experts.

Validation In Access?

1
I'm trying to create a validation rule that will only allow a date after the date entered in a previous field.

For example.
I have 2 fields, 'Date Start School' and 'Date End School'
How do I create a validation rule that makes sure 'Date End School' is after 'Date Start School'


I don't know whether that makes sense to anyone, but any help would be appreciated.

Thanks in advance
Apr 14 '08 #1
1 1220
nico5038
3,080 Expert 2GB
To test multiple fields I don't use a validation rule, as it's not sure which field will be filled first...
You need to know that the user is finished entering data before testing, that's why I always have a [Save] button to do all the testing. My code "behind" that button looks like:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSave_Click()
  2. Dim txtMessage As String
  3. On Error GoTo Err_btnSave_Click
  4.     ' init error message 
  5.     txtMessage = ""
  6.     ' Check fields in reverse order to set focus to the first
  7.     If Not Len(NZ(Me.Description)) > 0 Then
  8.         txtMessage = "Description empty ?" & vbCrLf
  9.         Me.Description.SetFocus
  10.     End If
  11.     If Not Len(NZ(Me.Severity)) > 0 Then
  12.         txtMessage = "No Severity?" & vbCrLf & txtMessage
  13.         Me.Severity.SetFocus
  14.     End If
  15.     If Not Len(NZ(Me.Type)) = 0 Then
  16.         txtMessage = "Recordtype empty ?" & vbCrLf & txtMessage
  17.         Me.Type.SetFocus
  18.     End If
  19.     ' Check error found
  20.     If Len(txtMessage) > 0 Then
  21.         MsgBox txtMessage
  22.         Exit Sub
  23.     End If
  24.  
  25.     DoCmd.Close
  26.  
  27. Exit_btnSave_Click:
  28.     Exit Sub
  29.  
  30. Err_btnSave_Click:
  31.     MsgBox Err.Description
  32.     Resume Exit_btnSave_Click
  33.  
  34. End Sub
  35.  
Here you can test first or both fields are filled and when they are, test for their relation.

Clear ?

Nic;o)
Apr 14 '08 #2

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

Similar topics

3
by: Ben Binskin | last post by:
Im rather new to developing mysql/php applications and am after some advice on handling user validation for a web based system, ive implimented a number of ways and would like to know which way is...
21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
7
by: Mathew Hill | last post by:
I am a beginner to the more technical aspects of Microsoft Access (2000) and was wondering if any one can help? I have a field in a table called: ADMIN NUMBER This field should have 4...
3
by: BrianB830 | last post by:
Hello all, I have a quick question regarding an MS Access database I'm creating. In the entity "ORDER", I have the attributes "Order Date" and "Delivery Date". I need to create a validation...
4
by: earwicker | last post by:
I recently deployed a web application which contains a user registration form with the usual fields: name, address, email, password, etc. Each of the TextBoxes uses a validation control to verify...
3
by: Bob Alston | last post by:
I have a routine to copy data to new versions of my app via insert into sql statements. Unfortunately, due to evolution of my app, sometimes the new version has more restrictive editing than an...
5
by: Kyle | last post by:
On my Development System, all the page validation controls work fine (WinXP Pro + SP2, VS.NET 2003, .NET v1.1.4322). On the Production System, none of the page validation controls are working...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
5
by: Kuldeep | last post by:
Framework: Visual Studio 2005 Technology: ASP.NET 2.0 Language: C#.NET 2.0 Hi All, We have developed a Web Application on Visual Studio 2005 (ASP.NET 2.0) and deployed it on the Client's...
7
by: sharsy | last post by:
Hi guys, I would like to setup a validation rule for a database in microsoft access that restricts data entry so that a certain field can only be filled in if another field has a specific answer...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
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...

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.