473,407 Members | 2,359 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,407 software developers and data experts.

How to prevent "backdating" using a date interval query?

Hello All,

First off I don't know if "backdating" is the correct term for this issue, but I'm unsure of what else to call it.

I have a form that has two fields (we'll call them A & B) that provide parameters for a query, both of which are formatted as General Dates. They are used to select an interval of dates to find which contracts end between those two dates.

The query works perfectly at the moment and returns the data that it should, but there is a minor loophole I would like to close up before launching the database company wide - if the user selects a second date(field B) that happens to be before the first date(field A) results still come back...

Is there any way to have an error message appear if the user selects a date in Field B that occurs before Field A? I would imagine there is but due to my amateur Access knowledge I can't seem to figure it out.

Any help would be greatly appreciated! Thanks!
Nov 12 '10 #1

✓ answered by NeoPa

In the Validation Rule property for control (not field) A use <=[B].
In the Validation Rule property for control B use >=[A].

4 2992
NeoPa
32,556 Expert Mod 16PB
In the Validation Rule property for control (not field) A use <=[B].
In the Validation Rule property for control B use >=[A].
Nov 13 '10 #2
I entered the code as the Validation Rule for the start date and when I tried to run the query it said that the value I entered did not meet the validation rules for that field/control. I'm assuming that because it tries to validate that the start date is before the end date when there is no end date entered yet it kicks out the error.

I could possibly be putting the rule in the wrong place, you mention control A & B, but how is that different than the field properties? Where do I find the control validation rule if it is different?

Thanks again for the help!
Nov 16 '10 #3
I was able to figure it out! I did not enter the validation rule for Control A and just set Control B using your suggested code and it works perfectly now!

Do you see any potential problems not have control A to be set to
Expand|Select|Wrap|Line Numbers
  1. <=[b]
?
Nov 16 '10 #4
NeoPa
32,556 Expert Mod 16PB
Good question Tim.

First let me clarify. The Validation Rule can certainly be set for the field rather than the control. The item on the form however, is not a field, but a control. If you want to go to the table design and change things there, then that would even be preferable, on the probably reliable assumption that this relationship is required universally for the data in the table (It is conceivable however, that data in a form can have different requirements from those in the table itself. Rare but can happen).

It is also usual for controls to be named differently from the fields they are used to represent. For instance, a TextBox control bound to a field named [Description] is usually named [txtDescription] or similar.

In answer to your question Do you see any potential problems not have control A to be set to <=[B], I would say yes. I'm afraid I do. If ever the [B] date is entered ok, but then the [A] date is updated afterwards, the Validation Rule would not apply, and it would be possible to enter an invalid date. Not a very likely scenario I accept, but possible. Let me suggest an alternative response for you, which deals with this situation more fully :

In the Validation Rule property for field A use <=Nz([B],#12/31/9999#).
In the Validation Rule property for field B use >=Nz([A],#1/1/1900#).
Nov 17 '10 #5

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

Similar topics

4
by: Lynn | last post by:
On a form I have Date_Start Date_End I have a new Date_Start1 Date_End1 which the use inputs. I need to validate that Date_Start1 and...
6
by: Access Newbie | last post by:
I'm using Access 2000 and I'm trying to create a pass-through query to append all the data from a local table to a remote table. I'm using the SQL query editor in MS Access to create the query (I...
1
by: Sunil Korah | last post by:
Hi, My table contains a date field "DateOfVisit" and I have the following query SELECT Patients.PID, Patients.Lastname, Patients.FirstName, Patients.DateOfVisit, Patients.ToReport FROM...
1
by: mikevde | last post by:
Hi, I want to select data from a range of dates i.e over a 1 month period I've tried this: SELECT * FROM table WHERE DATE_SUB(Date(), INTERVAL 30 DAY) but the query isnt working as it is...
6
by: Peter Herath | last post by:
I want to create a dynamic report using a crosstab query...... pls someone look into my attached example database and help me out to do the report generation.... example is like dis...: there...
1
by: c8tz | last post by:
This is a query I have created that picks up the top 3 dates for this data (for example) : Tree Pos2 Date 1 15 23/08/2005 1 20 12/02/2006 1 32 15/10/2006 ...
1
by: aneinander | last post by:
I'm beginner and getting following error message, please help. The table contains transaction date, account number, branch, etc. And need to show previous transaction date or next transaction date...
3
by: shawnmiller77 | last post by:
Need Help ASAP! History: Installed new SBS 2003 server on Monday. Migrated IIS, website and current Access database over to new server. I did not develop the website or Access database. Former...
3
by: MBMSOFT | last post by:
Any idea How to prevent from different date/time format on different pc I've heard that I should create my own system time function in VBA which will not depend from the local pc system date/time...
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: 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...
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
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...
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...
0
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...

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.