Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    update query results when report is made.

    I have a query which will produce a list of all the jobs we have approved. (shown below)




    Code:
    SELECT SiteT.Site_Name, [StatusO&MT].[O&M Status], JobT.[O&M Charged]
    FROM SiteT INNER JOIN ([StatusO&MT] INNER JOIN JobT ON [StatusO&MT].[O&M_Status_ID] = JobT.[O&M_Status_ID]) ON SiteT.Site_ID = JobT.Site_ID
    WHERE ((([StatusO&MT].[O&M Status])="approved"));
    I would like to apply this to ONLY the jobs which are returned from the query:

    Code:
    UPDATE [JobT] SET [JobT].[ O_M_Charged] = '1';
    I want the UPDATE code to be in a separate query so I can run it when I produce the report. That way I can make sure every time I make a report, we're not charging for the same job twice.

    Obviously the second piece of code there will change the whole table not the query. Is there any special way to reference a query? or is it the same as referencing a table?

    Or is there a different way to do this?

    thanks in advance, Andy.


    EDIT: after this works I can easily not include the ticked boxes.

  2. #2
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    you reference a query just like you reference a table.

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Okay, So, if create a query using the second code I provided (referencing the query).

    Then I'll make a macro to produce the report then update using the new query. Then add that to a button in an admin area...

    Does that sound like the right way to go about this to you?

    thanks for your answer.

  4. #4
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    I'm having a hard time understanding what you're trying to accomplish. When doing a SELECT query, you can reference a query just like a table. But you're talking about an UPDATE query. Are you trying to dynamically change a query? I'm lost.

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Each job has a manual and we charge for the production of the manual but only after its approved. The report I generate shows all jobs that have had an approved manual. I then send this to the client and they pay for "x" amount of completed manuals basically.

    The update is changing checkboxes to true. So I only want to apply it to the ones I have put into a report (once a month).

    I'm just trying to ensure we don't charge them twice.

  6. #6
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    Your second query needs to do something like UPDATE [JobT] SET [JobT].[ O_M_Charged] = '1' WHERE [primarykey] in [firstquery].[primarykey];

  7. #7
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    looking into this now James, thanks.

  8. #8
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Am I right in thinking I can run reports on click event of a button? I can also assign this code to that button too?

  9. #9
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    http://prntscr.com/8w9q6a please see the screenshot. I have the query I'm referencing open, But it still asks me to define the ID.

  10. #10
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    http://prntscr.com/8w9slq here is the design view also. I cant see what's wrong. although obviously something is. Hopefully someone here can help!

  11. #11
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    I have it working! thanks James.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update Label Texts with Query Results
    By schwabe in forum Programming
    Replies: 9
    Last Post: 05-14-2014, 05:34 PM
  2. Update Balance AfterPayment Is Made
    By 2tMonte in forum Programming
    Replies: 1
    Last Post: 11-29-2013, 01:19 PM
  3. Replies: 15
    Last Post: 11-18-2013, 01:49 PM
  4. Replies: 7
    Last Post: 02-26-2013, 10:37 AM
  5. Replies: 2
    Last Post: 06-25-2012, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums