Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
  1. #16
    Kimberly2015 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    10
    One Table Doc_AP_MASTER

    SELECT DOC_AP_MASTER.[Fac ID], DOC_AP_MASTER.[Pharm-Doc], DOC_AP_MASTER.FACILITY_NAME, DOC_AP_MASTER.[Res ID], DOC_AP_MASTER.[Resident Name], DOC_AP_MASTER.[Antipsychotic Medfication], DOC_AP_MASTER.[SS/LS], DOC_AP_MASTER.[T/AT], DOC_AP_MASTER.[Dementia Medication], DOC_AP_MASTER.[AP Low Dose with Dementia Med], DOC_AP_MASTER.[Parkinsons Medication], DOC_AP_MASTER.[PRN Only], DOC_AP_MASTER.PHARMACY, DOC_AP_MASTER.DOCTOR, DOC_AP_MASTER.PHYSICIAN_NAME, DOC_AP_MASTER.[Other Prescriber], DOC_AP_MASTER.ALTIDFILE
    FROM DOC_AP_MASTER;

  2. #17
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    What is the name of the query?

  3. #18
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    good question; where did I read of Snapshot being deprecated?... I want to say in a 2013 what's new....but I need to get my hands on that and reconfirm....but for some reason it was in my memory banks.....

    okay so 65 interations and then can't open more table error - - other objects open that can be closed?....need to clear memory along the way it would seem....

  4. #19
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Not sure what the name of your query is. I suggest you do not use the Report's filter property for selecting the appropriate ALTIDFILE. Instead, edit the Query Object's SQL. You can do this on the fly and it should be better performing than editing the Report's SQL or the Report's Filter property. Understand that the code below needs to be used "as is". You must edit the name of the Query. Other than that, the code should work, fingers crossed. (No way for me to test it here) Also, the Query Object must be dedicated for this procedure because it will always have a WHERE clause.

    Code:
    
    Dim strFileName As String
    Dim strWhere As String
    Dim strPath As String
    Dim strSQL As String
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    Dim qdf As DAO.QueryDef
    
    strFileName = ""
    strWhere = ""
    strPath = "C:\Antipsychotics Testing\PC\"
    strSQL = "SELECT DOC_AP_MASTER.[Fac ID], DOC_AP_MASTER.[Pharm-Doc], DOC_AP_MASTER.FACILITY_NAME, DOC_AP_MASTER.[Res ID], " & _
             "DOC_AP_MASTER.[Resident Name], DOC_AP_MASTER.[Antipsychotic Medfication], DOC_AP_MASTER.[SS/LS], " & _
             "DOC_AP_MASTER.[T/AT], DOC_AP_MASTER.[Dementia Medication], DOC_AP_MASTER.[AP Low Dose with Dementia Med], " & _
             "DOC_AP_MASTER.[Parkinsons Medication], DOC_AP_MASTER.[PRN Only], DOC_AP_MASTER.PHARMACY, DOC_AP_MASTER.DOCTOR, " & _
             "DOC_AP_MASTER.PHYSICIAN_NAME, DOC_AP_MASTER.[Other Prescriber], DOC_AP_MASTER.ALTIDFILE " & _
             "FROM DOC_AP_MASTER "
             
    Set db = CurrentDb
    Set rs = db.OpenRecordset("SELECT [ALTIDFILE] FROM [DOC_AP_MASTER]", dbOpenSnapshot)
        If rs.RecordCount < 1 Then
            MsgBox "No records found to export.", vbInformation, "Unable to export!"
            Set rs = Nothing
            Set db = Nothing
            Exit Sub
        End If
    Set qdf = db.QueryDefs("QueryName")
        While Not rs.EOF
        
            strFileName = rs![ALTIDFILE]
            strWhere = "WHERE [ALTIDFILE] = '" & strFileName & "'"
            qdf.SQL = strSQL & strWhere
            DoCmd.OutputTo acOutputReport, "Physician Summary", acFormatPDF, strPath & strFileName & ".pdf"
            rs.MoveNext
        
        Wend
        
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    Set qdf = Nothing

  5. #20
    Kimberly2015 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    10
    I thought I posted. I guess I didn't.

    @ ItsMe
    I don't have a query. It is being pulled into the report from the table. I think it is a crucial piece in making your code above work.

    @ NTC
    I don't know how to dump memory. How would you suggest doing that?

    Thank you both for helping. This is over my head but I am trying to learn.

    Thanks!

  6. #21
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Kimberly2015 View Post
    ...

    @ ItsMe
    I don't have a query. It is being pulled into the report from the table. I think it is a crucial piece in making your code above work.
    ...
    Where did you get the SQL from? No matter, create a query and save it. Place the name of the query where the red text is. Use the name of the query in your report's RecordSource and save the report.

  7. #22
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I just thought of another thing. It may or may not be an issue. But there may be a chance file names are being duplicated. In that case, you would need to add something unique to the file name. Maybe something like
    Code:
    DoCmd.OutputTo acOutputReport, "Physician Summary", acFormatPDF, strPath & strFileName & rs![Fac ID] & ".pdf"

  8. #23
    Kimberly2015 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    10
    I haven't had a chance to test it out. The ALTIDFILE is unique -- it ultimately is a concatenated field of the FAC ID and PHARM-DOC

    Fingers crossed. I'll keep you posted!

  9. #24
    Kimberly2015 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Posts
    10
    Okay so the code pulls the report and names it uniquely with the ALTIDFILE however, when you open the pdf it's as if I just saved the report to a pdf. It doesn't separate the ALTIDFILE into individual PDF's. (It doesn't break the report so that each ALTIDFILE has only it's corresponding information)

    That was not explained well by me. I apologize.

  10. #25
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    What is the name of the query defined in the Report's RecordSource? What is the SQL of this query Object?

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Saving Reports
    By sdc1234 in forum Access
    Replies: 2
    Last Post: 07-18-2013, 12:22 PM
  2. Replies: 2
    Last Post: 06-25-2013, 05:48 AM
  3. Replies: 1
    Last Post: 01-17-2012, 02:51 PM
  4. Saving Multiple Records at once
    By EvanRosenlieb in forum Access
    Replies: 5
    Last Post: 10-18-2011, 12:39 PM
  5. How to automate printing and saving reports
    By lilynet in forum Programming
    Replies: 0
    Last Post: 02-10-2009, 01:33 PM

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