473,657 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Validation Rule Question. Help Greatly Appreciated.

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 rule here. The
delivery date must come after the order date.

Would anyone be able/willing to help?

Thanks everyone!

Nov 13 '05 #1
3 2022
On Sun, 02 Oct 2005 02:10:41 -0500, BB*******@adelp hia-dot-net.no-spam.invalid
(BrianB830) wrote:
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 rule here. The
delivery date must come after the order date.

Would anyone be able/willing to help?

Thanks everyone!


I'm pretty sure you can't use a database-level validation rule to enforce
that. You'll just have to use a form for input, and validate there. Do the
validation check in the BeforeUpdate handler on the form.

Let's assume you have 2 textboxes on your form bound to the 2 fields, and the
controls are called txtOrderDate and txtDeliveryDate . Let's also assume for
purposes of example that both fields are required and this is enforced with
field settings, so BeforeUpdate for the form cannot be triggered without
filling in both dates first. In this case, your even handler might look
like...

Private Sub Form_BeforeUpda te(Cancel As Integer)

If Me!txtDeliveryD ate < Me!txtOrderDate Then
Cancel = True
Me!txtDeliveryD ate.SetFocus
MsgBox "The Delivery Date must be on or after the " & _
"Order Date."
End If

End Sub

Note - for many reasons, it's best not to include spaces in table or field
names, and avoid using key words as names ("ORDER" is an SQL key word). It is
conventional in Access to use Camel Case with a "tbl" object type prefix for
table names, and Upper Cammel Case (e.g. tblOrder, OrderDate,
OrderDeliveryDa te). In the relational DB server world, lower case with
underscores is more common (e.g. sale_order, order_date, delivery_date).
Either of these styles will make sense in an Access database.
Nov 13 '05 #2
BrianB830 wrote:
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 rule here. The
delivery date must come after the order date.

Would anyone be able/willing to help?

Thanks everyone!


Using table validation, not field validation, you'd do something like:

[Delivery Date] >= [Order Date]

BTW, you might want to rethink your naming conventions, as meaningful as
your names are, "Order" and "date" are reserved words in Access/SQL and
can cause you a problem later on.
Nov 13 '05 #3
You *could* do this with a Check Constraint (in Access 2000 and later). This
would probably be more efficient but there are some drawbacks:

- it's poorly documented, and can only be created from VBA code, not from
the Access UI

- it doesn't give friendly error messages when the constraint is violated
(but you can name the contraint in a fairly friendly manner)

- Jet supports more flexible constaints than SQL Server, so you have to be
careful if there's a chance you might upgrade in the future.

If you're interested in this approach, take a look at:

http://support.microsoft.com/Default.aspx?kbid=201888

"BrianB830" <BB*******@adel phia-dot-net.no-spam.invalid> wrote in message
news:6b******** ************@gi ganews.com...
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 rule here. The
delivery date must come after the order date.

Would anyone be able/willing to help?

Thanks everyone!

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
298
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 characters and ONLY NUMBERS should be inputted. Does anyone know what the validation rule should be for this field?
9
2131
by: James Butler | last post by:
Our setup: Online db: MySQL Inhouse db: MS Access 97 with MySQL tables linked via ODBC Our issue: Almost every field updates successfully, except one. A scenario: Information is written to online db. We run an inhouse query to collect info from online db and update
6
3684
by: Chuck | last post by:
A97. A database has a table: tblA which has a single text field, B. It is a primary field, indexed and no duplicates. It is used as a lookup for table tblC. A form based on tblA is used to add new records. The Validation Rule: <>!! was made using the expression builder. The rule produces this error: The expression you entered in the Form control's Validation Rule doesn't contain the Automation object 'Tables' If I use simply: ...
2
2122
by: Ben.j.howard | last post by:
In my table i would like to create a validation rule for a yes/no field. I would like it, to only allow you to check yes, if two other fields are already ticked as yes. Example; Field 1: Order confirmed (yes/no) Field 2: Order ready to ship (yes/no) Field 3: Shipped (yes/no)
5
3186
by: Jeremy | last post by:
I have a vb .net 2003 app that uses access 2k as a backend. The main table has some validation rules (legacy stuff brought forward inadvertantly, and now we're stuck with 'em). The problem is, I do a dataadaptor.update, and an exception is thrown. I would prefer to validate before the update & tell the user to fix the data. dataset.hasErrors does not detect the validation violation. When the exception is thrown I can of course catch...
1
1739
by: RyanL | last post by:
All, I have an append query set up that pulls records off of one table and appends them to a linked table. However, when the query runs, it gives me an error message saying that the records could not be appended due to a validation rule error. The wierd thing is there are no validation rules set up for any of the fields in either table. All fields are the exact same type and have the same properties. Any thoughts would be greatly...
3
1284
by: KPR1977 | last post by:
I want to set a validation rule that will not allow me to input data in field1 in TableA that is not found in TableB under field2. Basically, Table B under field 2 has the following row entries: Apple, Pear, Lemon, Orange. When I input data in field 1 for Table A I want it to give me an error message if try and input Watermelon (since Watermelon doesn't exist anywhere in Table2.) If anyone could help me out with this, it would be much...
7
5967
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 (that is selected via a drop down list). Example Field1 - options are "In" or "Out" Field2 - options are "Join" or "Not Joining"
2
19457
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
8402
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7341
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.