Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using Graphs in Access Word Merge

Posted on 2011-02-15
8
Medium Priority
?
523 Views
Last Modified: 2012-05-11
I'm new to Access but I'm using Access 2010 data to generate some documents using the Word Merge feature. I am able to get data from queries in Access into my document just fine.

Now I want to generate some graphs based on this data for the Word Merge, but I'm having trouble figuring out how I'd do that. Do I generate the graph in an Access form then use the Word Merge to import it? Or do I try to create a graph in Word and use Access as the source? I've tried both - and couldn't figure it out.
0
Comment
Question by:DVation191
  • 3
  • 3
  • 2
8 Comments
 
LVL 31

Assisted Solution

by:Helen Feddema
Helen Feddema earned 500 total points
ID: 34899939
You export data, not objects like graphs.  There are various possibilities here.  I wouldn't use Word, but save reports with the graphs (or PivotCharts) to PDF format.  Maybe you could just import the data to a Word doc, and append a PDF doc with the graph.
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 1500 total points
ID: 34900105
Helen, pardon me for jumping in ...

A method I have used with success in the past is to create the graph in Access and then save it to a image file. You can then insert the image into your Word document.

Here is where I first learn how a while back: Email/Export Charts from Access
*** Note Even though a lot of the examples are in Access 97, most will work fine in Access 2000-2010.

There is also: Creating Charts with VBA in Word 2010
0
 
LVL 20

Author Comment

by:DVation191
ID: 34900410
I'll look into these suggestions but just wanted to note something before anyone else posted.

The challenge here is that I'm generating  hundreds of documents with the word merge function based on a table of information in Access. Some of the data in those records would best be displayed as a chart or graph and not as a raw number. I'm not sure any of the proposed solutions address that yet, but I'll certainly check.
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 1500 total points
ID: 34901056
That is exactly why I put charts in my reports in Access.  I do charting a lot in Access.

I do agree with Helen that you should probably look into using a report.  The Access RTF control can do lots of advanced formatting.  I use an Access report to generate letter all the time.

Really curious:
Since you are using Access 2010 which has a built-in RTF support, is there some reason you not using an Access report?  
0
 
LVL 20

Author Comment

by:DVation191
ID: 34906258
"Since you are using Access 2010 which has a built-in RTF support, is there some reason you not using an Access report"

Being new to Access, I did not realize that Access had the "word merge" functionality built in. I was under the impression that a report was just a single page document. I'll look into this as well.
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 1500 total points
ID: 34907852
Maybe this example will give you some insight on working with Access reports:

Batch Printing and Save As PDF

This example could easily be updated to send the PDF as an email.

0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 34938644
Here is some code that creates a filtered report for each record in a recordset, and saves it as a PDF and then emails it:
Public Sub SendInterventionEmails()
'Created by Helen Feddema 10-Jan-2010
'Last modified by Helen Feddema 10-Jan-2010

On Error GoTo ErrorHandler

   Dim appOutlook As New Outlook.Application
   Dim itm As Outlook.MailItem
   Dim rstIntervention As DAO.Recordset
   Dim lngCount As Long
   Dim lngID As Long
   Dim rpt As Access.Report
   Dim strFileName As String
   Dim strPrompt As String
   Dim strQuery As String
   Dim strRecordSource As String
   Dim strReport As String
   Dim strSQL As String
   Dim strTitle As String
   Dim strCurrentPath As String
   Dim strFileNameAndPath As String
   Dim strEmailSource As String
   
   strEmailSource = "qryInterventionEmail"
   strRecordSource = "qryMissingAssignments"
   strQuery = "qryMissingAssignmentsSingleStudent"
   Set dbs = CurrentDb
   Set rstIntervention = dbs.OpenRecordset(strEmailSource)
   strCurrentPath = Application.CurrentProject.Path & "\"
   
   'Use path selected with SelectFolder procedure
   'strCurrentPath = SelectFolder()

   With rstIntervention
      Do While Not .EOF
         lngID = ![StID]
         Debug.Print "Processing Student ID " & lngID
         strFileName = "Intervention Report for " & ![StFirst] _
            & " " & ![StLast] & ".pdf"
         strFileNameAndPath = strCurrentPath & strFileName
         
         'Create filtered query
         strSQL = "SELECT * FROM " & strRecordSource & " WHERE " _
            & "[StID] = " & Chr(39) & lngID & Chr(39) & ";"
         Debug.Print "SQL for " & strQuery & ": " & strSQL
         lngCount = CreateAndTestQuery(strQuery, strSQL)
         Debug.Print "No. of items found: " & lngCount
         If lngCount = 0 Then
            GoTo NextStudent
         End If
      
         'Open report with filtered query record source
         strReport = "rptMissingAssignmentsNew"
         DoCmd.OpenReport ReportName:=strReport, _
            View:=acViewPreview, _
            windowmode:=acWindowNormal
         Set rpt = Reports(strReport)
         DoCmd.OutputTo objecttype:=acOutputReport, _
            objectname:=strReport, _
            outputformat:=acFormatPDF, _
            outputfile:=strFileNameAndPath
         
         'Create email
         Set itm = appOutlook.CreateItem(olMailItem)
         itm.Subject = "MISSING WORK"
         itm.Body = "The attached file lists your missing assignments"
         itm.To = ![Email]
         itm.Attachments.Add Source:=strFileNameAndPath, _
            Type:=olByValue
         
         'For editing before sending
         itm.Display
         
         'For sending automatically
         'itm.Send
         DoCmd.Close objecttype:=acReport, _
            objectname:=strReport, _
            Save:=acSaveNo

NextStudent:
         .MoveNext
      Loop
   End With
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in SendInterventionEmails procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub

Public Function CreateAndTestQuery(strTestQuery As String, _
   strTestSQL As String) As Long
'Created by Helen Feddema 28-Jul-2002
'Last modified by Helen Feddema 10-Jan-2010

On Error Resume Next
   
   'Delete old query
   Set dbs = CurrentDb
   dbs.QueryDefs.Delete strTestQuery

On Error GoTo ErrorHandler
   
   'Create new query
   Set qdf = dbs.CreateQueryDef(strTestQuery, strTestSQL)
   
   'Test whether there are any records
   Set rst = dbs.OpenRecordset(strTestQuery)
   With rst
      .MoveFirst
      .MoveLast
      CreateAndTestQuery = .RecordCount
   End With
   
ErrorHandlerExit:
   Exit Function

ErrorHandler:
   If Err.Number = 3021 Then
      CreateAndTestQuery = 0
      Resume ErrorHandlerExit
   Else
   MsgBox "Error No: " & Err.Number _
      & " in CreateAndTestQuery procedure; " _
      & "Description: " & Err.Description
   End If
   
End Function

Open in new window

0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 34938649
In order to automate the process of putting graphs into the Word docs as images, or creating them as separate PDF files, you will need to somehow standardize them, perhaps working in batches, where each batch requires a graph of a certain type, which would have a corresponding report.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question