Hi
I was wondering if anyone could help me create a query in access which would do the following as i cant seem to work it out.
Currently i have two tables table 1 and 2. I want to create a query which selects ID, Description, Chase date, Receievd date from table 1 & Closedate and startdate form table 2.(These tables already have a inner join by the ID column)
The criteria i need is that when the query runs a inputbox appears where you enter a date and then the query takes that date and adds 21 (e.g. if the entered date was 17/11/2011, the query would add 21 to it so it would be 08/12/2011). It would then use that date and bring back any Chase date which are equal to or less than that date and that are blank in Receieved date, closedate and startdate.
However i am not sure how to do this? I am currently using the Query Design tool in design view, and i am having trouble entering the criteria. Can anyone help me?
Thank you
Jeskit![]()
Can you post your current attempt's SQL? In the design view, change to SQL view to show the SQL.
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
Hi
Thank youf ro replying.
Sure not a problem the SQL code is below:
Thanks,SELECT Table1.ID, Table1.Description,Table1.Chasedate, Table1.Receievddate, Table2.Closedate, Table2.startdate FROM Table2 INNER JOIN Table1 ON Table2.AppRefID = Table1.AppRefID;
Jeskit
Hi,
I have found out that what I actually need the query to do is different from what i posted first off!
What it needs to is take the same columns from the same tables, except for the criteria it needs to first create a new invisible column which takes the chase date and add 21 to it, return only blank rows in Receieved date, closedate and startdate.
It should also, when the query runs a inputbox appears where you enter a date. It should then take that date and compare it agianst the chase date + 21 column.
I hope this makes sense!
So it needs to only return results when Recieved date, close date, and start date are all null?
See here for instructions on creating a parameter query. Please repost your SQL after changing your query to a parameter query.
http://office.microsoft.com/en-us/ac...001117077.aspx
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
Hi,
Thanks for replying!
The code with the criteria of Recieved date, close date, and start date as null from below,
However now i need a criteria which add an invisible column which takes the Chase date and adds 21 to it, then add code which says when the query is run have the user provide a date and then return all the rows where the date in the new invisible column is equal to or less than the date provided.SELECT Table1.AppRefID, Table1.Item,Table1.DateChased, Table1.DateRcd, Table2.StartDate, Table2.AppClosed FROM Table2 INNER JOIN Table1 ON Table2.AppRefID = Table1.AppRefID WHERE (((IsNull([Table2]![StartDate]))=True) AND ((IsNull([Table2]![AppClosed]))=True) AND ((IsNull([Table1]![DateRcd]))=True));
Any help would be appreciated!
Thank you
In a new column in your QBE, type ChasePlus21: DateAdd("d",21,[ChaseDate])
Make sure the check box is unchecked if you don't want it visible.
In the criteria type #&[Enter a Chase Date]&# This will give the user a prompt to enter a date.
Here is a link on DateAdd for your understanding
http://www.techonthenet.com/access/f...te/dateadd.php
and here is a link that explains parameter queries.
http://www.techonthenet.com/access/q...parameter1.php
Last edited by alansidman; 11-22-2011 at 08:05 AM. Reason: Add links
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
HI,
Ok i have tried that however i keep getting a message of "The expression you entered has an invalid date value" when i enter "#&[Enter a Chase Date]&#" into the criteria box.
Sorry, my bad. Was confusing two routines. Try this
[Enter Chase Date]
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
Hi,
OK i have got it running but its not bringing back any dates.
From what i know about the dates in the tables if i put in 26/11/2011 it should return any rows which are equal too or less than the chase date + 21, so it should return 1 row.
With the criteria set to a specific date, which it is for the criteria I gave you, it will return only data for that date. You will need to use either a less than or greater than symbol before the date if you want a range of dates.
This link will help you to formulate and understand queries. Perhaps it is time for a little self study.
http://www.techonthenet.com/access/queries/index.php
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
Hi,
Thank you for all your help, your query has worked.
However do you know if it is possible to have a criteria which says <= [table3].[date] where table1].[id] = 1?
As the way i was trying to build the query was not working due to other constraints in the database so i have had re-design, so the query now does the same but instead of using a message box to get the chase date it takes the date in a certain table (table3).
However i need to add an extra on constraint on to <= [table3].[date] criteria so it only looks at the date in table 3 which has 1 in the id column of table 3.
Is this possible?
Thanks for your help
What happens when you try this:which says <= [table3].[date] where table1].[id] = 1?
<= [table3].[date] and[table1].[id] = 1
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks