title: How to refresh/requery report in access VBA before auto-exporting it on database launch
body: <p>I searched thoroughly and tried many different solutions, but I can't seem to get it to work, even though it shouldn't be that difficult.</p>
  
  <p>I have an access database which automatically sends reports by e-mail, every monday morning, when the database is opened. The problem is I can't get the reports to show the most recent data in the charts. The procedure is as follows (with Report1 as example)</p>
  
  <p>(Users open a .accdr version of the database)
  Upon opening this code runs when the head form loads (form_load event):</p>
  
  <pre><code>If Weekday(Now(), 2) = 1 Then   
  If Forms![Head Form]![Once subform].Form![ID] = 0 Then
  DoCmd.OpenQuery "UpdateOnce1", acViewNormal, acEdit
  DoCmd.SetWarnings False
  DoCmd.OpenReport "Report1", acViewPreview
  DoCmd.RunSavedImportExport "Export-Report 1"
  
  Dim strSql
  Dim db As Database
  Set db = CurrentDb()
  Dim Outlook
  Dim rng
  Dim OutApp As Object
  Dim OutMail As Object
  
  Set OutApp = CreateObject("Outlook.Application")
  Set OutMail = OutApp.CreateItem(0)
  
  On Error Resume Next
  With OutMail
  .To = "number of mail adresses"
  .CC = ""
  .BCC = ""
  .Subject = "Report 1"
  .HTMLBody = ""
  .Attachments.Add ("T:\.....\Report1.pdf")
  .Send
  
  End With
  
  
  DoCmd.Close acReport, "Report1"
  
  End If
  End If
  </code></pre>
  
  <p>So if it is monday, and the code hasn't run yet, Report 1 is openend, exported to PDF, added as an attachment and then mailed via outlook.</p>
  
  <p>As you can see I currently tried opening the reports before calling the code to mail the pdf, in hopes of refreshing it before it exports. But it doesn't seem to be working unfortunately, because the report doesn't show the most recent data.</p>
  
  <p>Any ideas on how I can refresh/requery the report before it is exported &amp; mailed? Much appreciated.</p>
  
  <p>Tim</p>