LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Refresh Query based on variable

I want to refresh a query based on a variable. I have the following
which does not work.

Sub AddDetailSheet()

Dim Proj As Variant
Proj = InputBox("Enter Project Code, as 00-000-000-000-000", "Project
Code")

Range("G2").Select
With Selection.QueryTable
.Connection = Array(Array( _

"ODBC;DSN=Clockworks;Description=Clockworks;UID=sa ;APP=Microsoft Office
2000;WSID=ERIKEWING;DATABASE=Intranet;LANGUAGE=us_ english;Net" _
),
Array("work=DBMSSOCN;Address=172.30.1.110,1433;Tru sted_Connection=Yes"))
.CommandText = Array( _
"SELECT tbl_TimeSlips1.Year, tbl_TimeSlips1.Month,
tbl_TimeSlips1.Week, tbl_ISProjects.Description, tbl_ISPersonnel.Name,
tbl_ISPersonnel.Department, tbl_ISProjects.GLCode,
tbl_TimeSlips1.Hours, tbl_IS" _
, _
"Personnel.Rate, tbl_TimeSlips1.Notes,
tbl_ISProjects.Capitalized" & Chr(13) & "" & Chr(10) & "FROM
Intranet.dbo.tbl_ISPersonnel tbl_ISPersonnel,
Intranet.dbo.tbl_ISProjects tbl_ISProjects, Intranet.dbo.tbl_TimeSlips1
tbl_TimeSli" _
, _
"ps1" & Chr(13) & "" & Chr(10) & "WHERE
tbl_TimeSlips1.ContractorCode = tbl_ISPersonnel.RecordID AND
tbl_TimeSlips1.GL = tbl_ISProjects.RecordID AND
((tbl_TimeSlips1.Year=2006 Or tbl_TimeSlips1.Year=2005) AND
(tbl_TimeSlips1.Hour" _
, _
"s0) AND (tbl_ISProjects.Capitalized In (0,1,3)) AND
(tbl_ISPersonnel.Status In ('Associate','Contractor')) AND
(tbl_ISProjects.GLCode In (Proj)))" & Chr(13) & "" & Chr(10) & "ORDER
BY tbl_ISProjects.Description," _
, " tbl_ISPersonnel.Name")
.Refresh BackgroundQuery:=False
End With

End Sub

Any help would be appreciated. TIA

Greg

 
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
MS Query Refresh Based on Dynamic Named Range bwilk77 Excel Discussion (Misc queries) 0 May 26th 09 02:17 PM
How can I 'Enable Automatic Refresh' for Query Refresh by default Anand Deshpande Setting up and Configuration of Excel 0 December 10th 06 04:47 AM
Query Refresh-Enable Automatic Refresh Dialogue Box Terri Excel Discussion (Misc queries) 0 May 6th 05 08:21 PM
Timing of automatic query refresh and macro pivot table refresh dutty Excel Programming 2 December 1st 04 07:19 PM
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) Anant[_2_] Excel Programming 1 August 6th 03 04:22 AM


All times are GMT +1. The time now is 02:22 PM.

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

About Us

"It's about Microsoft Excel"