Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 MS Access Update Query using Expressions
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

dayve
Forum Moderator

USA
5820 Posts

Posted - 21 February 2006 :  19:01:44  Show Profile  Visit dayve's Homepage
I feel silly asking this question, but never had a need for doing it this way.

Is it possible to use MS Access Queries to update a field using an expression without using VBA? The process in which I need to do is quite easily done using VB and VBA, but I am trying to assist someone that wants to just run the query. So for example, there is an expression that was created in the SELECT query that needs to be used in an UPDATE query. Unless I am missing something very obvious, I can't seem to do it.

TIA.

UPDATE: Here is their SQL statement

SELECT s8_prop.PROP_ID, s8_prop.FEDERAL_TAX_NO, s8_prop.PAYEE_NAME, s8_prop.INSP_RESULTS, s8_prop.INSP_DATE, s8_prop.NEXT_INSP, DateAdd("yyyy",+1,DateAdd("m",0,[INSP_DATE])-DatePart("d",DateAdd("m",0,[INSP_DATE]))) AS newNextInsp
FROM s8_prop
WHERE (((s8_prop.INSP_RESULTS)="Pass"));


they want to use the result of newNextInsp to update s8_prop.NEXT_INSP

UPDATE 2: Figured it out. I thought I could use the expression name, but had to use the actual formula instead.

UPDATE s8_prop SET s8_prop.NEXT_INSP = DateAdd("yyyy",+1,DateAdd("m",0,[INSP_DATE])-DatePart("d",DateAdd("m",0,[INSP_DATE])))
WHERE s8_prop.INSP_RESULTS)="Pass";


Edited by - dayve on 21 February 2006 19:13:15

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 February 2006 :  19:22:00  Show Profile  Send ruirib a Yahoo! Message
That statement will never work using SQL alone, cause Access SQL does not support those date functions. You will be able to execute in Access but not from ASP, for example.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 21 February 2006 :  19:22:32  Show Profile  Visit dayve's Homepage
quote:
Originally posted by ruirib

That statement will never work using SQL alone, cause Access SQL does not support those date functions.


it did work. I see you modified your response.


Edited by - dayve on 21 February 2006 19:24:55
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 21 February 2006 :  19:24:14  Show Profile  Send ruirib a Yahoo! Message
In Access, yes, outside of it no. As I just edited my reply, it would not work from an ASP page. DateAdd and DatePart are VB functions, not SQL functions.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

davemaxwell
Access 2000 Support Moderator

USA
3020 Posts

Posted - 22 February 2006 :  12:05:35  Show Profile  Visit davemaxwell's Homepage  Send davemaxwell an AOL message  Send davemaxwell an ICQ Message  Send davemaxwell a Yahoo! Message
You could use a stored query if the updating would be very limited (ie, same field same way every time).

Dave Maxwell
Barbershop Harmony Freak
Go to Top of Page

davemaxwell
Access 2000 Support Moderator

USA
3020 Posts

Posted - 22 February 2006 :  12:06:19  Show Profile  Visit davemaxwell's Homepage  Send davemaxwell an AOL message  Send davemaxwell an ICQ Message  Send davemaxwell a Yahoo! Message
Oops. Just realized you already figured it out.

NEVER MIND! Nothing to see here. Move along...move along...

Dave Maxwell
Barbershop Harmony Freak
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 22 February 2006 :  16:46:19  Show Profile  Visit dayve's Homepage
quote:
Originally posted by davemaxwell

Oops. Just realized you already figured it out.

NEVER MIND! Nothing to see here. Move along...move along...


yeah, thanks. I knew of a handful of solutions that I could have easily done, but as I pointed out, I was doing this for someone that did not want it done any other way but through an Access query. worse case scenario, I would have convinced them to do it another way, but I was interested in the possibility and Access seemed to be able to handle the date functions I needed.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.33 seconds. Powered By: Snitz Forums 2000 Version 3.4.07