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. - If DateDiff("d", Me.MOT_Renewal_Date, Now()) < 15 Then
-
MsgBox "Vehicles Due MOT Renewal", , "Renewal Due"
-
If DateDiff("d", Me.Tax_Renewal_Date, Now()) < 15 Then
-
MsgBox "Vehicles Due Tax Renewal", , "Renewal Due"
-
If DateDiff("d", Me.Insurance_Renewal_Date, Now()) < 15 Then
-
MsgBox "Vehicles Due Insurance Renewal", , "Renewal Due"
-
-
End If
-
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
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
@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
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
@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
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
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
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
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)>
Thanks I already have conditional formating just wanted the message as form opened but thanks a million for that info would make perfect sense
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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?
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
| |