Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add 1 to date field if holiday 1

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,966
US
I have a table that has dates. I have another table of holidays.

I want to update the table with dates by 1 day if the day is a holiday.

Below is a query that is giving me a "Operation must use an updateable query" error.

Code:
UPDATE Dates SET Dates.OutputDate = Dates.InputDate + (SELECT count(*) FROM Holiday WHERE Dates.InputDate BETWEEN Dates.InputDate AND Dates.InputDate);

Swi
 
Your query where condition makes no sense because it will always return true. You can use DCount() in place of the subquery:
SQL:
UPDATE Dates 
SET Dates.OutputDate = Dates.InputDate + DCount("*", "Holiday","[WHERE CONDITION HERE]");
You really need to correct your logic prior to running the update query.

Duane
Hook'D on Access
MS Access MVP
 
Ok, thanks you are correct about the WHERE statement, my apologies. Looks like it is working however what if I would want to convert this to an ADO connection string in VB? I don't believe DCOUNT will work.

Thanks.

Swi
 
I'm not aware of how this can be done with an ADO connection to an Access table. I'm also not sure what your object might be or how often this needs to be performed.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top