Results 1 to 5 of 5
  1. #1
    MrDummy is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    50

    Report not saved for current file but for all records

    Hello,



    I have a custom ribbon with below Code attached to a button. I also have a Navigation Form with multiple tabs. When I click the button it activates the FileSaveAsDialog for the current file on the tab and the filename is correct. After clicking "Save" it does not save just the current record it saves all the records into one file.

    How to save only the current file? Any help would be appreciated.

    Code:
        Application.FileDialog(msoFileDialogSaveAs).InitialFileName = "UN" & Format(UNNO, "0000") & ".pdf"
          
        intChoice = Application.FileDialog(msoFileDialogSaveAs).Show
                        
        If intChoice <> 0 Then
       
        DoCmd.OutputTo acOutputReport, "rptUNLookUp", acFormatPDF, "UN" & Format(UNNO, "0000") & ".pdf"
        
        End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    your query that runs the report needs to pull only 1 record.
    I use a form for users to select what they need filtered, ie., select the clientID from a combo box.
    the query will not pull only that data...

    select * from table where clientID = forms!frmRpts!cboClient

  3. #3
    MrDummy is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    50
    OK thank you. The form is already based on a query and is on in of the tabs. It is a "Record Look up" form.
    The issue here is that when I use the Code with a button on the Tab itself (so basically when i make it part of the form) the code works perfectly. So it saves only the current record that is visible in the form. But I moved the button to my own Customized Ribbon and now it saves all instead of the current record.
    So for some reason it has lost track of the current record that is displayed.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Does the query use the FULL path to the form?.....forms!frmRpt!txtboxID

  5. #5
    MrDummy is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    50
    Hello,

    It seems that for some reason the Me.MMDGF doesn’t do what I expected it to do. It loses the ID-number and instead saves all the records. Alternative is shown in below Hyperlink. This does the trick.
    Thanks for the replies.

    https://bytes.com/topic/access/answe...here-condition

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

Similar Threads

  1. Replies: 1
    Last Post: 10-29-2015, 07:03 AM
  2. Word file saved from VBA is corrupted
    By riggsdp in forum Programming
    Replies: 5
    Last Post: 11-26-2014, 12:11 PM
  3. Replies: 4
    Last Post: 06-05-2014, 02:24 PM
  4. Replies: 5
    Last Post: 09-26-2013, 08:35 AM
  5. Changing File Location in saved imports using VBA
    By akshatagarwal93 in forum Import/Export Data
    Replies: 3
    Last Post: 07-23-2012, 10:47 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