Results 1 to 9 of 9
  1. #1
    PaulY is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2024
    Location
    Vancouver BC
    Posts
    3

    DoCmd.Close acReport / acSaveYes randomly NOT saving

    I have a process that I run monthly which updates the month in several Text Boxes of various reports (month / year in the report title and the month number of the source query). This process has worked like a charm for years. However, since one or two years ago, it has OCCASIONALY happened that I've had to run this process with some minor updates, and the reports simply "do not save". I work in my local computer (database and everything is in my local SSD drive), so it's not an issue with the "network" etc. My line of code is:



    Code:
    DoCmd.Close acReport, ReportName, acSaveYes
    The two or three times this has happened before, I have rebooted my computer (the fool-proof "when-everything-else-fails" method, right?) and, voila, then it works OK. Today, however, there was no way in hell I could make this process save the reports (the process is called for 62 different reports). I'd run the process (and I added msgboxs before and after the DoCmd line to confirm it was getting there), but the reports would not save (the "Modified date" would indeed remain as the last time I ran the process in early January). I even changed the code to:

    Code:
    DoCmd.Close acReport, ReportName, acSavePrompt
    So it would manually prompt me to save. Yet, to no avail, the reports would remain untouched, with the January "Modified date"

    Eventually I just manually updated the Text Boxes I needed to change for each of the reports (I only needed to change 4 of the reports, 9 Text Boxes in each). But my concern is, why is this happening...? Why would MS Access simply ignore the DoCmd.Close acReport, ReportName, acSaveYes command, apparently on a whim...? It's as if MS Access had a "cache" of the reports and simply refused to update them (occasionally)... If I try running this process again tomorrow, it would probably work OK... It's very frustrating, the inconsistency, and having that line of code simply "not executing", without any error or warning message of any kind... Has anyone have any similar experience with the DoCmd.Close acReport comand? Any idea of what can be happening...? Many thanks in advance for any insight on this.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Save is for design view?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I'm surprised it ever "worked" at all, and after some 30 years of dabbling in Access would have to agree with WGM. I have seen this method save record changes that were made in forms but it's common for people to think it's only for saving form design, thus the form must be in design view. I don't use it because it's almost never necessary.

    However a report is supposed to be a different view of records which allows you to present data in ways that forms cannot. Or it makes the sharing of information easier. It is also supposed to be that this view reflects what the underlying recordsource returns to the report and that is not done by altering report fields, it is done by altering what the recordsource passes to the report. In other words, trying to alter what a report shows by altering report fields is like putting the cart before the horse. This may just be another one of those things we seem to be seeing that stops working because it never should have, which is likely triggered by updates to the application itself. It seems that somehow you have been able to affect the recordsource and save the change by monkeying with the report but that is not something I would ever attempt.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    PaulY is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2024
    Location
    Vancouver BC
    Posts
    3
    I open the report in design view:

    Code:
    DoCmd.OpenReport ReportName, acViewDesign, , , acHidden
    Then I update the controls I have to update, For example:

    Code:
    rpt.Controls("lblMonth").Caption = Left(MonthPeriod(fPer), Len(MonthPeriod(fPer)) - 5)
    Then save it. Like I said, it has worked like a charm for over 15 years...

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Wow, why not just do it when the form is opened to view/edit?

    No clue as to why it has stopped, but that method is not even needed.

    Overkill so say the least.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    PaulY is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2024
    Location
    Vancouver BC
    Posts
    3
    "Form"? There are no forms involved in this process. It's a monthly update, I only need to update the data and print the reports...

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    When I have done this, the report title (or whatever section) just came from, or was calculated from, or concatenated from, data that came from the report query. Sorry to say you are doing this in a convoluted fashion. If you're focused on why it doesn't work now, I have nothing to offer on that track.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Quote Originally Posted by PaulY View Post
    "Form"? There are no forms involved in this process. It's a monthly update, I only need to update the data and print the reports...
    Sorry, I meant report, but the logic would be the same anyway.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    How do you update the Modified Date that you say doesn't change? Do you actually write the new date in the caption or control source of a control or do you use a function like you show us for the lblMonth? Maybe it does save but your function returns the wrong value.
    Have you considered using a local tblReportsSetting table to store all the info that you need to change monthly and simply using dLookups to bring those values into your reports? That way you simply edit the table but you don't need to touch any reports.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. DoCmd.Close ignored
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 06-18-2022, 07:31 PM
  2. DoCmd.Close
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 02-13-2021, 12:00 PM
  3. DoCMD.Close not always working
    By Canadiangal in forum Programming
    Replies: 14
    Last Post: 10-21-2020, 07:08 PM
  4. VBA code after DoCmd.Close acForm
    By Miles R in forum Forms
    Replies: 9
    Last Post: 04-11-2020, 03:28 PM
  5. DoCmd.Close Not Working
    By kdbailey in forum Access
    Replies: 6
    Last Post: 12-11-2013, 07:35 PM

Tags for this Thread

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