Run code If date Passed

sspreyer

Registered User.
Local time
Today, 04:06
Joined
Nov 18, 2013
Messages
251
Run code If date Passed issues!!!!!!

Hi ,
you lovely lot

i have some code that checks the last date in a table. The code is :
Code:
DateOfBackup = Nz(DLookup("BackupDate", "Newsdate", "BackupDate=date()"), 0)
If DateOfBackup [COLOR=Red]>=[/COLOR] Date Then      

DoCmd.OpenForm "Teaminformer"
i want the form to open if the date has passed.

For some reason it doesn't trigger have i got the expression right ? The red text

thanks in advance

shane
 
Last edited:
i have some code that checks the last date in a table.

No you don't. You have some code to see if today's date is in your table. Your logic is really screwy, there's really no need for the NZ or the DateOfBackup variable:

Code:
DateOfBackup = Nz(DLookup("BackupDate", "Newsdate", "BackupDate=date()"), 0)

DateOfBackup is either going to equal 0 or today's date. That's it, those 2 values are the only possible ones that DateOfBackup can hold using the code you have written. When you look at your other lines of code, all of it can be condensed down using a DCount instead of a Dlookup:

Code:
Iif(DCount("BackupDate", "Newsdate", "BackupDate=date()")>0 Then DoCmd.OpenForm "Teaminformer"

That is logically equivalent to what you have now. However, I don't know if its what you want. Can you explain using simple english (no code) what you want to happen and when?
 
Thanks Plog!

Is there away then i can check last entered record date. If the date has passed the actual date run the code

thanks


shane
 
Backupdate is the field that tracks the date the record was entered could i use DLast find the last entered record check if the backupdate field has passed the actual date but havent got clue how to do this!

thanks

shane
 
I would use DMax. Read up on the link I provided. You can essentially replace your Dlookup with Dmax.
 

Users who are viewing this thread

Back
Top Bottom