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

Don't know what to write in criteria

Hi! It is urgent needs to be solved in 24 hours, please help!!!!
I am asked to built an information management system for the company who sells medical devices. According to legislation each type of product sold by the company should be tested every 12 month. My boss asked to create a report which gives a full of information of outdated products each year. The products which were not tested within the last 12 month are called as outdated products. In the criteria, I wrote:
Expand|Select|Wrap|Line Numbers
  1. IIF(DateDiff(m;[tbl_testmarks]![test_Date];Now())>12;"Outdated";"Valid")
However, I am having the products which were tested. What to do?
Jan 29 '13 #1
12 1331
Seth Schrock
2,965 Expert 2GB
Your criteria shouldn't have the IIF in it. Also, you need tbl_testmarks as part of your query (unless the reference in your code is to a form and the naming convention got left behind). So your criteria to just get those products which are out of date would be:
Expand|Select|Wrap|Line Numbers
  1. DateDiff("m", test_date, Date()) > 12
Jan 29 '13 #2
Anas Mosaad
185 128KB
I don't have the details about your systems but it seems to me that m should be wrapped in double quotes (i.e. "m").
Expand|Select|Wrap|Line Numbers
  1. IIF(DateDiff("m",[tbl_testmarks]![test_Date],Now())>12,"Outdated","Valid")
  2.  
Jan 29 '13 #3
It is MS Office 2013. I tried it, but it is giving me the whole list of products except 2012 dates.

DateDiff function shows the interval between two specified dates. in my table there are almost 800 records with 73 products each tested every 12 month after being sold. In 2012, there are some products which are not tested yet. When I typed the datediff function as you said sir Seth Schrock, i am having the test dates from the date the product sold till current date except products tested in 2012.

The company started selling from May 2006, and the query shows the records from 2006, however I don't need that.
Jan 29 '13 #4
zmbd
5,501 Expert Mod 4TB
Sherzodbek:
First here is the syntax for DateDiff Function

Second, we'll need a little more information about the field you're testing against if the records returned using Seths suggestion didn't work as expected.
Jan 29 '13 #5
NeoPa
32,556 Expert Mod 16PB
It is required for you to post a proper question. This lacks much of the detail required for this question to make good sense. Please see the sticky threads at the top of the forum for instructions on how to post a basic question then fill in the details you missed out from your question.
Jan 29 '13 #6
Seth Schrock
2,965 Expert 2GB
@NeoPa, the sticky threads don't appear at the http://bytes.com/topic/access/ website (which is what going through the Browse Topics > Microsoft Access/VBA takes you to). I can only see the sticky threads if I go to http://bytes.com/topic/access/answers/ website, so I doubt if the OP ever saw those.
Jan 29 '13 #7
NeoPa
32,556 Expert Mod 16PB
That's a very good point, and one I was unaware of. I'll speak to the Admins about it (I tried moving it and it didn't show then either).

For reference, the threads are :
NB. "The forum" would generally refer to the forum within which the current thread is located. That is Access/VBA Answers and not Access/VBA itself, although as many members navigate from the latter it is still important to make those threads unmissable. I always thought they were, so well done for highlighting that problem.
Jan 29 '13 #8
Rabbit
12,516 Expert Mod 8TB
You need to run the query against the max date per item to be tested. Also, there's no need to use the DateDiff function on the test date. Just return everything more than one year before the current date.
Jan 29 '13 #9
NeoPa
32,556 Expert Mod 16PB
Rabbit:
There's no need to use the DateDiff function on the test date.
Thank you. I had intended to make that point earlier but overlooked it :-(

Actually, using DateDiff() instead of DateAdd() will often lead to errors, as it will give you the nearest count of the specified interval, when you need an exact match (to the day).
Jan 29 '13 #10
zmbd
5,501 Expert Mod 4TB
And see there I learned something between the two functions! I had thought they returned essentially the same thing; thus, didn't suggest using dateadd
Jan 29 '13 #11
Rabbit
12,516 Expert Mod 8TB
I would use DateAdd on the Now() function. But not on the fields unless necessary. It's more efficient because it still allows for the use of any indexes that might be there.
Jan 29 '13 #12
NeoPa
32,556 Expert Mod 16PB
Rabbit:
I would use DateAdd on the Now() function
Essentially very good advice, but I would never use the Now() function when you are working with dates (as opposed to Date/Time values). Instead use the Date() function, but apply the DateAdd() to that as Rabbit says, definitely.
Jan 30 '13 #13

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

Similar topics

0
by: Farooq Khan | last post by:
hi, my development team has been assigned a project that involves writing our own Web service. i happen to be a C++ programmer, new to C#/ASP.net. i dont know where to begin with......any...
2
by: Pavel Novotny | last post by:
H I'm trying to import a | seperated text from string variable which represents a tabl with several fields, eg 6124079|PRIRUBA 11 DN250 PN6;CSN131160.0;11369.1;CSN131005.50|KS|11,100000|3437,...
0
by: arunavlp | last post by:
hi, I am new to .net , i am using VB.Net (Web form). I dont know how to pass parameters to stored function. Regards, Arun.S
2
by: hojjatnikan | last post by:
please help me this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
2
by: Tiruak | last post by:
Hi there. Thanks in advance for the people reading and trying to help. I'm very begginer using flash and action script, and I tryed to do this one navigation menu. Since I dont have experience...
2
by: Sreenivas | last post by:
I dont know how to compile cpp programs with gcc as i am new to gcc and cpp. could anybody help me out? Thanks&Regards, Srinivas Reddy Thatiparthy.
2
by: shwetaT | last post by:
i m working in php domain and i dont know much about php,so will u plz suggest me some good sites through which i learn php very well n fast
8
risk32
by: risk32 | last post by:
Hi all. I have a really confusing problem. I'm using Swing and I'm trying to do a confirmation box : int reply; String message = "Do you want to input another number?"; String title = "Input...
2
by: sailormoon | last post by:
this information i put in data.txt 11221 MOHD IRFAN 80 70 11222 NURUL FITRAH 80 90 11223 MOHD FARHAN 70 80 11224 WAFFIN WARDAH 80 60 11225 SYAMSUL 50 50 99999 TAMAT 0 0 #include<fstream.h>
2
by: sometingsometing | last post by:
hi, I am new and dont know what went wrong. from Tkinter import * import tkMessageBox from pysqlite2 import dbapi2 as sqlite class door: global simpleprint
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.