Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MS Query Refresh Based on Dynamic Named Range | Excel Discussion (Misc queries) | |||
How can I 'Enable Automatic Refresh' for Query Refresh by default | Setting up and Configuration of Excel | |||
Query Refresh-Enable Automatic Refresh Dialogue Box | Excel Discussion (Misc queries) | |||
Timing of automatic query refresh and macro pivot table refresh | Excel Programming | |||
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) | Excel Programming |