Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 08-13-2012, 07:53 AM   #16
Sketchin
Newly Registered User
 
Join Date: Dec 2011
Location: Calgary
Posts: 575
Thanks: 107
Thanked 41 Times in 40 Posts
Sketchin is on a distinguished road
Re: Open Query works under command button but not After Update event?

Code:
UPDATE tblReservations SET tblReservations.CategoryID = [Forms]![frmReservations]![txtCategoryID], tblReservations.Portfolio = [Forms]![frmReservations]![chkPortfolio]
WHERE (((tblReservations.ReservationID)=[Forms]![frmReservations]![TxtReservationID]));

Sketchin is offline   Reply With Quote
Old 08-13-2012, 08:00 AM   #17
pr2-eugin
Super Moderator
 
pr2-eugin's Avatar
 
Join Date: Nov 2011
Location: Bournemouth, UK
Posts: 8,498
Thanks: 68
Thanked 2,067 Times in 2,014 Posts
pr2-eugin has a spectacular aura about pr2-eugin has a spectacular aura about pr2-eugin has a spectacular aura about
Re: Open Query works under command button but not After Update event?

Should they not be included inside " & forms!... & ".. Thus changing your code as
Code:
UPDATE tblReservations SET tblReservations.CategoryID = " & [Forms]![frmReservations]![txtCategoryID] & ", tblReservations.Portfolio = " & [Forms]![frmReservations]![chkPortfolio] & "
WHERE (((tblReservations.ReservationID)=" & [Forms]![frmReservations]![TxtReservationID] & "));
also remeber to enclose the Strings (if there were any) with '" & [Forms]![frmReservations]![chkPortfolio] & "'
__________________
Regards,
Paul Eugin

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
!
Windows 7 Professional, MS Access 2010
---------------------------------------------------------------------------------------------------------------------
If the above post has helped you, please click the scales
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
or click the 'Thumbs up'. Cheers.

---------------------------------------------------------------------------------------------------------------------



pr2-eugin is offline   Reply With Quote
Old 08-13-2012, 08:17 AM   #18
bob fitz
AWF VIP
 
Join Date: May 2011
Location: Essex England
Posts: 3,521
Thanks: 52
Thanked 681 Times in 664 Posts
bob fitz has a spectacular aura about bob fitz has a spectacular aura about bob fitz has a spectacular aura about
Re: Open Query works under command button but not After Update event?

Paul
Actually, I don't think the quote marks are required because this is the sql of a saved query.

Sketchin
Have you actually looked at the table and checked that the update has failed. Until you posted the sql I had assumed that it was a SELECT query that would be displayed. An UPDATE query of course displays nothing.

__________________
Bob Fitzpatrick
Microsoft Community Contributor Award (2011)
If this helped, please click the scales at the bottom left of this posting.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Many thanks.


I have never failed. I have found a thousand ways that do not work!
bob fitz is offline   Reply With Quote
Old 08-13-2012, 08:51 AM   #19
Sketchin
Newly Registered User
 
Join Date: Dec 2011
Location: Calgary
Posts: 575
Thanks: 107
Thanked 41 Times in 40 Posts
Sketchin is on a distinguished road
Re: Open Query works under command button but not After Update event?

Yes, it for sure isn't working. It definetly works if I just manually run the query, or put the code behind a command button.
Sketchin is offline   Reply With Quote
Old 08-13-2012, 12:26 PM   #20
Sketchin
Newly Registered User
 
Join Date: Dec 2011
Location: Calgary
Posts: 575
Thanks: 107
Thanked 41 Times in 40 Posts
Sketchin is on a distinguished road
Re: Open Query works under command button but not After Update event?

I have actually had a similar problem earlier using an update query in an after update event. I wonder if there is some definitive documentation on this situation?
Sketchin is offline   Reply With Quote
Old 08-13-2012, 12:40 PM   #21
spikepl
Eledittingent Beliped
 
spikepl's Avatar
 
Join Date: Nov 2010
Location: San Serriffe
Posts: 6,144
Thanks: 77
Thanked 980 Times in 958 Posts
spikepl is a jewel in the rough spikepl is a jewel in the rough spikepl is a jewel in the rough
Re: Open Query works under command button but not After Update event?

There is no "situation" - you have code after execution of which you claim you have no change in your data. Either the code runs or it doesn't. If it does run, either the query criteria are satisfied or aren't. Have you checked that?

1. Change the query by removing the criteria - simply to check if it runs
2. If it does run, then in the code, on the line just priro to the one running the query, debug.print the values of the controls used in the criteria of the query.

spikepl is offline   Reply With Quote
Reply

Tags
action query , after update , query

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a command button to run a query and open form Johnny Drama Queries 3 05-25-2010 06:43 AM
Command button to open form and update subform ssworr Forms 3 06-09-2008 02:51 PM
SQL statement works in query, but on command button fedupwithaccess Modules & VBA 2 02-08-2007 03:26 AM
Update Query Command Button Lamb2087 Forms 4 02-12-2003 01:26 PM
command button works only once grahamhill Reports 0 03-05-2002 06:30 AM




All times are GMT -8. The time now is 04:05 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World