I have a form with a button. I will like to click the button, have it open a report that contains a chart. Then export that chart to a jpg file. The current code crashes access when I close the opened report. This works with a form with a chart but I can't get it to work with a report. Any ideas?
Private Sub btnimg_Click()
sDirectoryName = BrowseDirectory("Find and select where to export the Image file.")
txtFileLocation = sDirectoryName
strRpt = "MonthlyCostByGroupings"
DoCmd.OpenReport strRpt, acViewPreview
Dim grpApp As Object
Set grpApp = Reports!MonthlyCostByGroupings.OLEUnbound0.Object
grpApp.Export txtFileLocation & "\Chart.jpg"
Reports!MonthlyCostByGroupings.OLEUnbound0.Locked = False
Reports!MonthlyCostByGroupings.OLEUnbound0.Enabled = True
Set grpApp = Nothing
Reports!MonthlyCostByGroupings.Action = acOLEClose