View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JakeyC JakeyC is offline
external usenet poster
 
Posts: 107
Default When does the Access query run at worksheet open?

On 8 Mar, 19:59, Wood Grafing
wrote:
Okay, I cleaned the code up a bit. I also decided to disable the automatic
updating of the access query, since I'm going to be e-mailing this form to
others, and most don't have access to the database. Still curious about the
original question tho. I found a workaround, but curiousity is killing this
cat.

Private Sub Workbook_Activate()

Dim strTotal, strRes, strUnres As String

strTotal = Sheets("Count").Range("C2").Value
strRes = Sheets("Count").Range("C3").Value
strUnres = Sheets("Count").Range("C4").Value

MsgBox "Resolved Issues: " & strRes & " " & Chr(13) _
& "Unresolved Issues: " & strUnres & " " & Chr(13) _
& "Total Issues: " & strTotal, vbOKOnly, "Tallies"

End Sub


You could explicitly refresh the query as part of the Workbook_Open.
Depending on where it is, use something like:

ThisWorkbook.Sheets("Sheet1").Range("A1").QueryTab le.Refresh
BackgroundQuery:=False

before your MsgBox line. If you don't want users without database
access to do this, you might need to add a Yes/No MsgBox before this.

The 'BackgroundQuery:=False' makes sure that the MsgBox won't appear
before the refresh is complete.