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

How do you force a user to enter the correct date while comparing 2 date fields

How do you force a user to enter the correct dates (In & Out dates) while comparing 2 date fields in MS Access. User should get an error message indicating "Out date should be greater than In date.
Nov 5 '14 #1
3 1114
twinnyfo
3,653 Expert Mod 2GB
stress999,

Much like in your other thread, the general code will be the same. But, if you want to prevent the user from moving on, just add code that disables any controls that would allow them to move along.

Assuming that the user enters Date1, then enters Date2, then they click a "Search" button, for example, just disable the Search Button if the dates don't meet the criteria:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub txtDate1_AfterUpdate()
  4.     VerifyDates
  5. End Sub
  6. Private Sub txtDate2_AfterUpdate()
  7.     VerifyDates
  8. End Sub
  9. Private Sub VerifyDates()
  10.     If Not (IsNull(Me.txtDate1) Or IsNull(Me.txtDate2)) Then
  11.         If Me.txtDate2 < Me.txtDate1 Then
  12.             Me.txtWarning = "Date 2 must be after Date 1"
  13.             Me.cmdSearch.Enabled = False
  14.         Else
  15.             Me.txtWarning = ""
  16.             Me.cmdSearch.Enabled = True
  17.         End If
  18.     End If
  19. End Sub
Hope this hepps!
Nov 5 '14 #2
Thx Twinnyfo, mission complete.
Nov 5 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Great to hear it! Glad we could be of service!
Nov 5 '14 #4

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

Similar topics

6
by: Piotr Pietrowski | last post by:
Hello everybody, I have a *big* problem. I thought its not that big problem for you professionals... Anyway, I have a begin date which has 3 dropdown boxes (day/Month/Year). The same for the...
3
by: biltz | last post by:
i made a programe in which by using scanf..the user enter the password...but is there any function..or something else..so which , what ever enter the user its changeinto "*" not its shows what he...
2
by: Bob | last post by:
Hi, I have a wrong result when testing today against a date fetched from a table in excel. The value in excel is: 14/12/2006 (european format). When today is after that value in excel, the...
3
by: getmeidea | last post by:
Hi all, I have a table, account_transactions(trans_rid int primary key COMMENT 'Transaction ID', trans_date date COMMENT 'Date of transaction', ...
7
by: bluemoon9 | last post by:
Hi, I have a field call MRN. The property is text and max length is 8. In the data entry form, I have it as a combo box names cboMRN. I would like to force user to enter exactly 8 digits, if user...
3
by: vinpa | last post by:
Hello, I wish to have the user enter a date range (i.e. 01/01/2009 ---> 12/31/2009) to retrieve data to populate part of my report, and then populate another column with the same date range, but...
0
by: tasawer | last post by:
Hi, I have date and time fields for when the vehicle left the car park and when it returned. (dateout timeout datein timein) how can I create a query to search for the exact date and time to...
1
by: eshie | last post by:
I have a field called Service Date which contains the following data example: 10/1/2010-11/1/2010 How do I extract each date into 2 separate fields (begin date/end date)? Thanks!
9
by: James Bowyer | last post by:
I'm having a problem where two dates that (I think) should be able to be compared against each other (I'm trying to narrow down a set of results by a date to/from). However, it doesn't seem to work....
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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
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
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.