Solved

Update Query

Posted on 2013-01-04
9
252 Views
Last Modified: 2013-01-06
Experts,

I want to update the TASKS.DueDate if DueDate = Current Date.
If equals Current Date then Add 1 day.
format of [DueDate] = Short Date

I am making an update query for this.

I am not sure if I can use an IIF in the criteria section.  
If I can then I dont know the syntax.

thank you.
0
Comment
Question by:pdvsa
  • 4
  • 3
  • 2
9 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 38745033
'Assuming 'Current Date' means whatever the current date is, and not a column name

UPDATE TASKS
Set DueDate = DateAdd("d", 1, DueDate)
WHERE DueDate = Date
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38745063
<No Points wanted...>

Remember that you don't have to make a dedicated saved query.

You can run Jim's SQL like so from a button:

Dim strSQL as String
strSQL ="UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate = Date "
Currentdb.execute strSQL, Dbfailonerror

In this way you are not creating saved queries that can be accidentally run, (or worse deleted), by accident.
This also keeps your object count low.

;-)

JeffCoachman
0
 

Author Comment

by:pdvsa
ID: 38745121
Jim thank you... That should be my answer although not at a computer now to test.

Jeff:  thanks for that tip.  I was wondering about how an expert would do that.   The button method is nice.  I will use that.  I feel obligated to award you some points for that tip.

Thank you both
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38745210
No Points wanted for me...
;-)

Jim answered your question directly here.

I just posted some extra info that Jim or any other expert could have posted...

Take it as a late Holiday present...

;-)

Jeff
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Closing Comment

by:pdvsa
ID: 38745329
Thank you.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38745357
Thanks for the grade.  Good luck with your project.  -Jim
0
 

Author Comment

by:pdvsa
ID: 38748876
Jim / Jeff:

Finally at a computer and I am testing under the button method.
Wondering if you know why I get an error of "too few paramters" error 3061  
I am running the button from a report built on the table "TASKS" (if that makes a difference)

thanks..

error
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38749088
Since you're writing VBA to pass a T-SQL statement, gotta pass the date outside of the quotes so that it passes the date, and not text called 'Date'

strSQL = "UPDATE TASKS Set DueDate = DateAdd('d', 1, DueDate) WHERE DueDate=#" & Date() & "#"

Open in new window

0
 

Author Comment

by:pdvsa
ID: 38749478
thank you Jim.  that worked perfectly.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now