Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update Query

Posted on 2013-01-04
9
Medium Priority
?
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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
 

Author Closing Comment

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

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 66

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

618 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