Results 1 to 8 of 8
  1. #1
    MayaMia is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Aug 2012
    Posts
    10

    Print Command Button - Report Not Populating with New Data

    Hello. I recently setup a database with a form that contains a command button to print a report (actually there are many command buttons tied to different reports.) All worked fine, so I moved the database to a different location on the network (not sure if this has anything to do with my problem, but I thought I'd make you aware of it) for others to begin using. Now, when I use the form to enter a new record, the reports do not populate with any data from the new record; however, if I pull up one of the older records (which I entered while testing the database and before I moved it) the reports populate with the data. It's like any new records entered are not pulling through to the reports. I need to be able to print the report with ONLY the current record shown on the form; not all records in the query. Also, I need to be able to print the report with the data right after it is entered into the form. The code tied to the command button is:



    Private Sub VocSurvey_Click()
    On Error GoTo Err_VocSurvey_Click
    Dim strDocName As String
    Dim strWhere As String
    strDocName = "Vocational Survey"
    strWhere = "[ClaimNumber]='" & Me!ClaimNumber & "'"
    DoCmd.OpenReport strDocName, acNormal, , strWhere
    Exit_VocSurvey_Click:
    Exit Sub
    Err_VocSurvey_Click:
    MsgBox Err.Description
    Resume Exit_VocSurvey_Click

    End Sub

    I appreciate any help or advice you can give me. Thank you.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by MayaMia View Post

    ...Now, when I use the form to enter a new record, the reports do not populate with any data from the new record...

    ...it's like new records entered are not pulling through to the reports...

    Code:
    Private Sub VocSurvey_Click()
    On Error GoTo Err_VocSurvey_Click
    
        Dim strDocName As String
        Dim strWhere As String
           
         strDocName = "Vocational Survey"
    
         strWhere = "[ClaimNumber]='" & Me!ClaimNumber & "'"
    
         DoCmd.OpenReport strDocName, acNormal, , strWhere
    
    Exit_VocSurvey_Click:
         Exit Sub
    
    Err_VocSurvey_Click:
         MsgBox Err.Description
         Resume Exit_VocSurvey_Click
        
    End Sub
    That's because the 'New Record' doesn't exist! At the point in time where you're clicking on the VocSurvey ('print') button, the Record has not been Saved/Committed! In your code, just below your Dim Statements, add the line in Red and see what happens:
    Code:
    Private Sub VocSurvey_Click()
    On Error GoTo Err_VocSurvey_Click
    
        Dim strDocName As String
        Dim strWhere As String
    
        DoCmd.RunCommand acCmdSaveRecord
        
        strDocName = "Vocational Survey"
    
        strWhere = "[ClaimNumber]='" & Me!ClaimNumber & "'"
    
        DoCmd.OpenReport strDocName, acNormal, , strWhere
    
    Exit_VocSurvey_Click:
        Exit Sub
    
    Err_VocSurvey_Click:
        MsgBox Err.Description
        Resume Exit_VocSurvey_Click
        
    End Sub


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Keep in mind that record entry/edit is committed to table when form closes, move to another record, or run code. So Linq is probably on the mark for your issue and solution.
    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.

  4. #4
    MayaMia is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Aug 2012
    Posts
    10
    Thank you for your responses. I added the line in red as indicated, but it did not correct the problem. I have even closed the form, reopened it AND closed the entire database and reopened it; neither one of these steps helped. The NEW data is still not populating on the form when I use the command button (but the old data does.) I opened the actual report through the Reports link on the Objects menu (not through the form) and the report contained the new data amd printed with it correctly. Unfortunately, I need this form to work with the command buttons as the people who will be using the database are not experienced enough to navigate through Access. It seems as though there is a disconnect between the new data, forms, and/or reports. I keep thinking it has something to do with moving the database, because everything worked perfectly before I moved it.....but I am also not an expert (or even close.) : ) Any help or ideas you can give me would be greatly appreciated. Thank you.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You mean none of the records added since the move show, not just the latest record? This is odd.

    Want to provide db for analysis? Follow instructions at bottom of my post.
    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.

  6. #6
    MayaMia is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Aug 2012
    Posts
    10
    Claims Follow Up Database - Copy.zip
    Quote Originally Posted by June7 View Post
    You mean none of the records added since the move show, not just the latest record? This is odd.

    Want to provide db for analysis? Follow instructions at bottom of my post.
    Here is a copy of the db (if I attached it correctly.) Thank you!!

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You are using ClaimNumber as the criteria but this is not a required field in the Claims table. Either make this the PK and a required field or use the ClaimID autonumber which is set as PK as the report criteria.
    strWhere = "[ClaimID]=" & Me!ClaimID
    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.

  8. #8
    MayaMia is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Aug 2012
    Posts
    10
    Quote Originally Posted by June7 View Post
    You are using ClaimNumber as the criteria but this is not a required field in the Claims table. Either make this the PK and a required field or use the ClaimID autonumber which is set as PK as the report criteria.
    strWhere = "[ClaimID]=" & Me!ClaimID
    That solved my problem. Thank you so much!!!

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

Similar Threads

  1. Print Preview Command Button Locks Access
    By DanKoz in forum Access
    Replies: 7
    Last Post: 03-19-2018, 12:34 PM
  2. Replies: 2
    Last Post: 04-02-2012, 04:34 AM
  3. Replies: 8
    Last Post: 11-08-2011, 05:11 AM
  4. Replies: 5
    Last Post: 08-22-2011, 11:24 AM
  5. Replies: 0
    Last Post: 02-22-2011, 05:04 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