Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default When does the Access query run at worksheet open?

Hello all,

I'm working on an excel file that will get information from a couple cells,
and put that into a msgbox at worksheet open. I have one problem tho, if I
put the code at the Worksheet_Open, it fires before the query is run, and the
msgbox has old info in it. I would like the msgbox to popup without running
a macro, so where do I put the code so it will fire after the query? Any
help is appreciated, and I hope I was clear enough.

Code I'm using:

Dim strTotal, strRes, strUnres As String

'Worksheets("Count").Visible = True
Sheets("Count").Select
Range("C2").Select
'strTotal = ActiveCell.Value
Range("C3").Select
strRes = ActiveCell.Value
Range("C4").Select
strUnres = ActiveCell.Value
'Worksheets("Count").Visible = False

MsgBox "Resolved Issues: " & strRes & Chr(13) _
& "Unresolved Issues: " & strUnres & Chr(13) _
& "Total Issues: " & strTotal, vbOKOnly, "Tallies"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default When does the Access query run at worksheet open?



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
  #3   Report Post  
Posted to microsoft.public.excel.programming
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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default When does the Access query run at worksheet open?

On 8 Mar, 23:08, "JakeyC" wrote:
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.- Hide quoted text -

- Show quoted text -


....and I should say add that line before you assign values to
variables...

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default When does the Access query run at worksheet open?

Thank you, just what I needed to know.

"JakeyC" wrote:

On 8 Mar, 23:08, "JakeyC" wrote:
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.- Hide quoted text -

- Show quoted text -


....and I should say add that line before you assign values to
variables...


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating excel worksheet from an Access Query Jai_Friday Links and Linking in Excel 0 March 13th 07 09:21 AM
Can I use MS Query in Excel like an Append Query in Access Sam Wardill Excel Discussion (Misc queries) 0 April 11th 06 02:41 PM
How to open Access recordset via Query in Excel VBA??? Hexman Excel Programming 4 March 29th 06 08:11 PM
Microsoft Query rejects "nz" function in Access Query Vaughan Excel Discussion (Misc queries) 0 May 4th 05 05:20 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 11:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"