Results 1 to 4 of 4
  1. #1
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24

    New data on Form not showing on Report

    I have a form that I will be using for inspecting building sites and Im wanting to produce a single report each time I finish the inspection.

    I have got it functioning but the report is only showing the data that has been previously saved, so no new data that I have entered into the form during the inspection is coming through to the report. But if I close out of the form, reopen and hit end inspection again all data will show in the report.



    So in instead of writing a command that will close and reopen the form prior to producing the report, is there a way around this, what am I missing.

    Code below.

    'Saves record, calls other functions and closes the form
    Private Sub Command43_Click()


    Me.InspectionStatus.Value = "Completed"
    DoCmd.Save
    Call Savereport
    Call PhotoTransfer
    DoCmd.Close acForm, "PreApprovalReport"


    End Sub


    'creates. prints and saves the report

    Function Savereport()
    Dim strDocName As String
    Dim strWhere As String
    Dim user As String
    Dim StrJobFile As String
    Dim JobFile As String
    Dim Filename As String


    Filename = Me!InspectionType & " " & Me!ID
    JobFile = Me![JobFile]
    user = Environ("UserName")
    Text53 = "C:\Users" & user & "\OneDrive\PCA work\Jobs" & JobFile & "" & Filename & ".pdf"
    StrJobFile = Me![Text53]
    strDocName = "143 inspection"
    strWhere = "[ID]=" & Me!ID


    DoCmd.Save
    DoCmd.OpenReport strDocName, acPreview, , strWhere
    DoCmd.OutputTo acOutputReport, "143 inspection", acFormatPDF, StrJobFile, , , , acExportQualityPrint
    DoCmd.Close
    End Function

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Record must be committed to table first. Record is committed when:

    1. close table/query/form

    2. move to another record

    3. run code to save

    DoCmd.Save does not save record, it saves the form. So running it with form not in Design view likely does nothing.

    For methods to programmatically save record review: http://allenbrowne.com/bug-01.html

    Please post code between CODE tags to retain indentation and readability.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    ditto for saving report.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24
    Me.Refresh worked, thanks for the tip.

    Ill keep in mind next time in regard for the tags, etc.

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

Similar Threads

  1. Replies: 9
    Last Post: 08-08-2016, 02:57 PM
  2. Replies: 3
    Last Post: 12-29-2014, 01:04 PM
  3. Replies: 15
    Last Post: 04-16-2014, 01:15 PM
  4. Replies: 4
    Last Post: 12-14-2012, 03:42 PM
  5. Duplicate data not showing in report
    By ashu.doc in forum Reports
    Replies: 2
    Last Post: 09-19-2012, 05:56 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