473,396 Members | 1,989 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.

Date queries

47
Hi,

Sorry to be reopening this thread. but i am still unable to get this solved. The code i have used is
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "NameOfTheReport", acViewPreview, , Date - 3
I get an error message saying "Compile Error : Can't find project or library"

If this is closed out, i can deliver my project. Please help!!!

Thanks
Neo
Jul 24 '08 #1
11 1806
puppydogbuddy
1,923 Expert 1GB
I think your problem is with Date - 3. If you are referring to the system date, the syntax should be as follows: Date() - 3
Jul 25 '08 #2
neosam
47
I think your problem is with Date - 3. If you are referring to the system date, the syntax should be as follows: Date() - 3

When i tried doing that, the paranthesis () just disappeared. and it ended up being the way it is now. Am unable to change that.
Jul 25 '08 #3
youmike
69
Since Access is looking for an SQL string clause without the "WHERE", I think you should try something like:

Expand|Select|Wrap|Line Numbers
  1. "DateFieldInQuery = #" & Date() - 3 & "#"
"DateFieldInQuery" is whatever is the name that you have assigned in the query to the date you want to test. The # before and after tells Access that the number returned by Date() - 3 should be teated as a date.
Jul 25 '08 #4
neosam
47
Since Access is looking for an SQL string clause without the "WHERE", I think you should try something like:

Expand|Select|Wrap|Line Numbers
  1. "DateFieldInQuery = #" & Date() - 3 & "#"
"DateFieldInQuery" is whatever is the name that you have assigned in the query to the date you want to test. The # before and after tells Access that the number returned by Date() - 3 should be teated as a date.
But would this not be a query? how do i insert this in the where clause in the code?
Jul 25 '08 #5
PianoMan64
374 Expert 256MB
But would this not be a query? how do i insert this in the where clause in the code?
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM Tablename WHERE Datefieldname =  # " & Date() - 3 & "#"
  2.  
Jul 25 '08 #6
PianoMan64
374 Expert 256MB
The way that you would put that into your openreport command is as follows:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "NameOfTheReport", acViewPreview, , "Datefieldname =  # " & Date() - 3 & "#"
  2.  
Jul 25 '08 #7
neosam
47
The way that you would put that into your openreport command is as follows:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "NameOfTheReport", acViewPreview, , "Datefieldname =  # " & Date() - 3 & "#"
  2.  
I still get the same error message. "Cannot find project or library" and the 'date' in the code is highlighted.
Jul 25 '08 #8
puppydogbuddy
1,923 Expert 1GB
try:
Format(Date(),"mm/dd/yyyy") - 3
Jul 25 '08 #9
MikeTheBike
639 Expert 512MB
Hi

I have had this problem a few times over the years. It seems to be a referencing problem (perhaps when using A2000 on a DB created in A2003 but in A2000 format), and yes the parentheses do disappear when Date() is used. These only seem necessary in Query designer. I have never found a satisfactory answer to this, but in the past, in desperation, I have resorted to Int(Now()) in stead of Date !!


MTB
Jul 25 '08 #10
Stewart Ross
2,545 Expert Mod 2GB
Hi. When Date() is no longer recognised as a valid function the problem seems to arise as a result of missing or incorrect project references for that installation, as MTB said. To trace which one it may be best to compare the project references for the 'problem' installation to those for a 'known good' PC running Access with no problems.

I experienced this on a laptop installation, and all the development databases I was working on failed on normal built-in functions - Date was just one of many that caused compile errors and other completely daft symptoms. There was a missing reference in my case, but in others I know of it was a conflicting reference (to the wrong version of a DLL). It's really annoying because there is actually nothing wrong with the underlying DBs or their code, and trying to trace non-existent errors is such a fruitless task.

-Stewart
Jul 25 '08 #11
neosam
47
Hi. When Date() is no longer recognised as a valid function the problem seems to arise as a result of missing or incorrect project references for that installation, as MTB said. To trace which one it may be best to compare the project references for the 'problem' installation to those for a 'known good' PC running Access with no problems.

I experienced this on a laptop installation, and all the development databases I was working on failed on normal built-in functions - Date was just one of many that caused compile errors and other completely daft symptoms. There was a missing reference in my case, but in others I know of it was a conflicting reference (to the wrong version of a DLL). It's really annoying because there is actually nothing wrong with the underlying DBs or their code, and trying to trace non-existent errors is such a fruitless task.

-Stewart
Well the int(Now()) command helps. Thanks guys......
Jul 28 '08 #12

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

Similar topics

6
by: BlackFireNova | last post by:
Using Access 2002 I am writing a report which draws data from several different tables. I can't link all the tables in a query, as some can not be related without truncating the data. I plan...
1
by: EnriqueM | last post by:
One question: I created an access database that has been extremely useful in my work. I dont' even know at what level of knowledge I am at. I read a lot about how to create a database, created many...
5
by: David B | last post by:
I have a number of queries, running one after the other, which do quite a complex calculation. A text box on a form provides the date for this routine. I have another routine I wish to do and it...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
10
by: Kenneth | last post by:
I have a Query that consist of a lot of different sales data, and one of the colums are different date. The date goes from 1jan2003 til 31jan2003. in this Query I only want the salesdata for...
2
by: carl.barrett | last post by:
Hi, I'm back with the same question as I still can't get it to display my data the way I want it to. The table lists information about a perpetrator involved with an anti social behaviour...
6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
9
by: mharrison | last post by:
Hello, I am developing a small java web-based car-pool booking system app which interacts with an access database. I am trying to write 2 queries: The first which will specify whether a given car...
19
by: eskelies | last post by:
I have two queries. My goal is to pull a range of numbers that fall on or in a certain date range. For example, $100 on 9/1/2007 and $200 on 9/24/2007. I want the date range to pick up both the...
3
by: murch.alexander | last post by:
I made a simple public function to set and return a date value (see below). I have a number of queries that call up the function to get the "As Of Date," which is typically set to today's date....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.