473,386 Members | 1,699 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.

VBA Date Problem

I am having great difficulty trying to resolve this. WCCNF1 should turn to yes for previous dates in 2015 not 2016. I cant get it to work using -1. If Year = 2015 it should turn to Yes. Can anyone help me?
If (Year(Nz([WCCClmDt1])) = Year(Date)()) Then
WCCNF1 = "Yes"
ElseIf (Year(Nz([WCCMRDt1])) = Year(Date)()) And _
(Year(Nz([wccmrdtwgt])) = Year(Date)()) And _
(Year(Nz([wccmrdthgt])) = Year(Date)()) Then
WCCNF1 = "Yes"
Else
WCCNF1 = "No"
End If
Aug 4 '16 #1
3 745
Seth Schrock
2,965 Expert 2GB
Try this:
Expand|Select|Wrap|Line Numbers
  1. If Year(Nz([WCCClmDt1], 0)) = (Year(Date) - 1) Then
  2.     WCCNF1 = "Yes"
  3. ElseIf Year(Nz([WCCMRDt1], 0)) = (Year(Date) - 1) And _
  4.         Year(Nz([wccmrdtwgt], 0)) = (Year(Date) - 1) And _
  5.         Year(Nz([wccmrdthgt], 0)) = (Year(Date) - 1) Then
  6.     WCCNF1 = "Yes"
  7. Else
  8.     WCCNF1 = "No"
  9. End If
You had extra parenthesis and I'm not sure where you put the -1 before, but this should work.
Aug 4 '16 #2
PhilOfWalton
1,430 Expert 1GB
Your question is not very clear.
If you are trying to get "No" if wccmrdtwgt is this year and "Yes" ir it is a previous year then this bit of SQL will work
Expand|Select|Wrap|Line Numbers
  1.  IIf(Year([WCCMRDt1])=Year(Date()),"No","Yes") AS Expr1
  2.  
If you need a different result you need to explain what input you have and what output you want

Phil
Aug 4 '16 #3
Already figured it out thanks.
Aug 4 '16 #4

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

Similar topics

5
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
1
by: OzThor | last post by:
ok, re my post about using date's to load differen .js files... thanks... have it working now.... well almost.... I have a quiz here that loads a new set of questions each day... the...
7
by: Andy Davis | last post by:
I have a table of data in Access 2002 which is used as the source table for a mail merge document using Word 2002 on my clients PC. The data is transferred OK but I've noticed that any dates which...
0
by: Luis Esteban Valencia | last post by:
Hi, I am using windows 2000 Pro with SP4 for development and database is access2000. Regional Setting is as follows: Regional Options: Your locale(location): English United States short date...
0
by: Arpicheck | last post by:
Hi, I am writing a page that contains a texbox, a calendar, and a rangevalidator. The range validator is testing the textbox for date values. There is an event, set up to fire, when the...
3
by: seegoon | last post by:
Hi to all. I have a small problem I hope someone can help me with. I am running a sql query to a csv file. The query searches for the total of a column between 2 dates. This is a copy of one of...
15
by: edouard.spooner | last post by:
Hi, I have a tricky SQL query problem that I'm having probs with. I have a table which resembles something like this Date | Price1 | Price2 | Price3 01 Jan 2006 | 100 | 100 | 100 02 Jan...
2
by: hardik | last post by:
hi friends, i am really surprized the way access behaves in date fields i mean it's all ok when you have us time zone or us servers but if you have diffrent timezone like uk then access creates...
0
by: mykhan | last post by:
I have been using access database with asp.net pages. I just realized a problem with date saving in access table. I didnt give any specific format for the date when saved in tables, because I wanted...
3
by: Neil Chinneck | last post by:
Hi everyone, I have a weird problem, and I cannot work out what's going on. I have a continuous form (frmEnterCosts) based on a query (qryEnterCosts). I have series of unbound combo boxes to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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...
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?
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
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
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.