 |
BOOK: Access 2003 VBA Programmer's Reference  | This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 6th, 2007, 02:11 PM
|
|
Registered User
|
|
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Concatenated dynamic date
Help! I'm an oracle dba, modifying access .mdb queries. The last programmer had the criteria for data selection as
between Date() and #01/01/2006#
The end result needs to be getting the totals between the current date and 01/01 of the current year.
I've tried several expressions and here's the latest:
#FORMAT(["01/01/" & Year(Date)],"mm/dd/yyyy")#
Another one, but CTOD wasn't recognized.
CTOD("01/01" & Year(Date))
This would be accomplished by a to_date in oracle, concatenating 01/01 and the dynamic year.
I'm also open to changing the query if necessary. I also know this is probably a no brainer and have poured through many google and access help information and looked at date formats, but I cannot get my syntax to work. Also, if there is a website you think would be useful for a novice access programmer, I'd like to know what that is.
Thanks ahead of time for your help.
|
|

February 20th, 2007, 04:58 AM
|
|
Registered User
|
|
Join Date: Oct 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try with cdate function
|
|

February 21st, 2007, 02:10 AM
|
|
Registered User
|
|
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Try this and tell me if this works (Paste this into the criteria box for the date field):
Between Date()-Format(Now(),"y")+1 and Date()
|
|

April 13th, 2007, 11:18 AM
|
|
Registered User
|
|
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for answering me. I've been away from this project for a little while and just thought to look. No, that doesn't work. The error message is
The expression you entered contains invalid syntax. You omitted an operand or operator, you entered an invalid character or comma, or you entered text w/o surrounding it with quotation marks.
I get this in the selection criteria or the expression builder when attempting to get the mm for a date field in the database. Here is what I put in the selection criteria:
Between Date()- Format(Now(),"yy")+1 And Date()
|
|

April 16th, 2007, 03:04 PM
|
|
Registered User
|
|
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I believe I've figured out that there must be a problem with the Design View and the date functions that have several arguments with them. So, Date() works, but DateADD does not. The interesting thing is I can go to SQL View and enter the sql I need and save. However, when I switch back to the Design View, there are vertical bars (|) instead of commas. If I attempt to switch back to SQL View, then an error is displayed about the illegal use of vertical bars. So, at this point, if I need to change my query, I'll have to wipe out the portions it can't handle, go into SQL View and write and save the new query.
I am currently on Windows XP SP2 and my msjet40.dll is at version level 4.0.8618.0, which appears to be the latest and greatest. If anyone has any ideas about how to fix what I am experiencing, I'd be
glad to hear it. I read about the sandbox problem, but my versions seem to be fine. I switched my sandbox registry level to a 3, but that didn't fix my problem.
Dale
|
|

June 11th, 2007, 10:13 AM
|
|
Registered User
|
|
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This will return the first day of the current year:
DateSerial(Year(Now()),1,1)
so you could use
between Date() and DateSerial(Year(Now()),1,1)
|
|
 |