Solved

If-then-else statement for dates

Posted on 2014-02-19
4
266 Views
Last Modified: 2014-02-19
Not sure how to write vb If statement with dates such as:

 If txtCalDate is > 30 days  Then etc..



Thanks
0
Comment
Question by:zkoda
  • 2
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 39871664
can you explain in plain english this line

 If txtCalDate is > 30 days


what is in "txtCalDate" ?
0
 

Author Comment

by:zkoda
ID: 39871680
Sorry - txtCalDate is the name of a field in a form.  If the date value is greater than 30 days then I'll take it from there.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39871698
<If the date value is greater than 30 days > you need two dates to do a comparison?

assuming the second date is todays date


if datediff("d",Date(),me.txtCalDate) > 30 then



end if

or

if datediff("d",me.txtCalDate,Date()) > 30 then



end if
0
 

Author Closing Comment

by:zkoda
ID: 39871709
Just what I needed - Thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now