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

DateDiff

geraldinegrieve
I have a table in access that holds data on vehicle there are 3 fields holding dates on MOT, Tax and Insurance renewal I am looking for 3 different messages on opening if date of any is within next 2 weeks e.g.
Expand|Select|Wrap|Line Numbers
  1. If DateDiff("d", Me.MOT_Renewal_Date, Now()) < 15 Then
  2.     MsgBox "Vehicles Due MOT Renewal", , "Renewal Due"
  3.     If DateDiff("d", Me.Tax_Renewal_Date, Now()) < 15 Then
  4.     MsgBox "Vehicles Due Tax Renewal", , "Renewal Due"
  5.     If DateDiff("d", Me.Insurance_Renewal_Date, Now()) < 15 Then
  6.     MsgBox "Vehicles Due Insurance Renewal", , "Renewal Due"
  7.  
  8. End If
  9.  
now i have tried various variations of this but all messages appear at all times regardless of dates any help greatly apprecipated Thanks in advance
Dec 12 '08 #1
9 1671
I have now tried this in a macro and works ok if 1st record holds the true data but not if it is the 2nd or any other record e.g.
Condition ([tax_renewal_Date]-Now())<15 Action Message Box
Condition ([MOT_renewal_Date]-Now())<15 Action Message Box
Condition ([Insurance_renewal_Date]-Now())<15 Action Message Box SO CLOSE but not quite correct
Dec 12 '08 #2
MindBender77
234 100+
@geraldinegrieve
Have you tried using "ElseIf". I added this to the code you provided. I believe this should correct or issue but, is just air code.

Note: You could also make 3 IF statements for each condition as well.

HTH,
Bender
Dec 12 '08 #3
Thanks for replying so quickly I did try an Else if but only does 1st message if true and stops and if 1st message not true then 2nd gets displayed and stops. I am not clear on your advice 3 seperate if statements because i did try that but all messages at all dates appeared Thanks in advance
Dec 12 '08 #4
MindBender77
234 100+
@geraldinegrieve
Here is making the 3 IF statements. No matter if the first if is true or false, it will then move to the next IF. The same will happen for the second IF etc.

Bender
Dec 12 '08 #5
That was also my understanding of it, but maybe I am putting it in the wrong place i have it in the Form oncurrent and it is not taking the criteria into consideration it is giving back all 3 messages regardless of dates
Dec 12 '08 #6
MindBender77
234 100+
If that is the case, it seems your DateDiff statement may be to blame. Have you tried debugging line by line to see how the criteria is being handled? Also, this might do nothing but, in your DateDiff statement, remove the empty parenthesis after Now. Without knowing what your project does, the OnCurrent should be fine.

So something like this:
DateDiff("d", Date1, Now) < 15

HTH,
Bender
Dec 12 '08 #7
Thanks a million for this I got it working so as if criteria is on first record then it gives message but if criteria is in any other record message doesn't appear until you click into the record so so close
Dec 15 '08 #8
missinglinq
3,532 Expert 2GB
if criteria is on first record then it gives message but if criteria is in any other record message doesn't appear until you click into the record
This would indicate that you're dealing with a Datasheet or Continuous View form, in which case it is only going to work as you've just described. The Form_Current event fires as you move to a record, so the warning for a given record won't pop up until you move the focus to that record. .

An alternative, for a Continuous or Datasheet view, would be to use Conditional Formatting to change the background color of the appropriate textboxes to indicate that the fee is due.

Welcome to Bytes!

Linq ;0)>
Dec 15 '08 #9
Thanks I already have conditional formating just wanted the message as form opened but thanks a million for that info would make perfect sense
Dec 16 '08 #10

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

Similar topics

4
by: CJM | last post by:
I have an ASP page that lists files and folders in a directory. I'm using a cookie to record the last time this page was visited, and I intend to show links that are created/modified from that date...
8
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 ...
6
by: Lofty | last post by:
Hi all. I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days...
1
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
5
by: sr | last post by:
Anyone know of a better way to simulate a datediff for C#, i.e., without referencing the VB.NET runtime? Only added the functionality that was needed for me so it is not the full implementation...
6
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error...
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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.