Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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
 
Old October 14th, 2004, 10:02 AM
Authorized User
 
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding value to a date & setting update criteria

Hi all,

I have a two column table in which the dates are stored in a mmddyyyy format. Now i have to create a query whereby i can check if the date that i have in my Datesupdate field for whether it is a monday or a tuesday etc and if it is then increase it by 1 but if the date in the Datesupdate field is a Friday then increase it by 3.. I have tried doing this in part and for increasing the date used:

[tbl_updatedate]![Datesupdate] + 1

where tbl_updatedate is my table and Datesupdate is my date field. But what happens is that i get the increased date as mm+1,dd,yyyy. It works with the format ddmmyy but i cannot give the date like that. Also for setting the criteria mentioned i am not sure how to make use of say IIf. I have seen the use of iif as given below in the Update field of the Update query:

= IIf(Weekday(Date())=1, [tbl_updatedate]![Datesupdate]+1, IIf(Weekday(Date())=2, [tbl_updatedate]![Datesupdate]+1, IIf(Weekday(Date())=3, [tbl_updatedate]![Datesupdate]+1, IIf(Weekday(Date())=4, [tbl_updatedate]![Datesupdate]+1, IIf(Weekday(Date())=5, [tbl_updatedate]![Datesupdate]+3)

but this would mean checking whether the day today is a Monday or Tuesday etc instead of checking the dates in the Datesupdate field for which day they are on . Could i also know what is the exact difference between what you are allowed to put in the update and the criteria row of any update query. For eg say how can one put

= IIf(Weekday(Date())=1, [tbl_updatedate]![Date]+1, IIf(Weekday(Date())=2, [tbl_updatedate]![Date]+1, IIf(Weekday(Date())=3, [tbl_updatedate]![Date]+1, IIf(Weekday(Date())=4, [tbl_updatedate]![Date]+1, IIf(Weekday(Date())=5, [tbl_updatedate]![Date]+3)

in the update field for doesn't it hold conditions or criteria within it.

Any Ideas!

Chow
Goels

P.S - Just to add, also i noticed that putting the above mentioned IIf statement in the Update field gives a pop-up box the tab saying "Enter Parameter Value" and the content being a text box with the heading tbl_updatedate. If i give it in the criteria row then i start getting an error that the 'destination should be specified'.


 
Old October 19th, 2004, 07:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Have you tried using the DateAdd function instead of merely doing a "+ 1" or a "+ 3"? That is

NewDate = DateAdd("d", 1, OldDate)


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division





Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing & Setting the margin of document... ravi_bachwala General .NET 1 August 9th, 2007 06:54 PM
Setting up & Connecting to SQL Server Scripts82 SQL Server 2000 1 March 9th, 2006 06:16 AM
Date criteria expression dpkbahuguna Beginning VB 6 2 February 24th, 2006 11:47 PM
* where date >= '"& dateVar &"' order by date wrofox Classic ASP Databases 5 February 24th, 2005 10:11 AM
ASP cache & IIS setting kalunalan Classic ASP Basics 2 February 25th, 2004 10:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.