Tranquil_Ape
New Member
- Joined
- Jun 20, 2008
- Messages
- 23
Ok i mentioned a week or so ago i would start the flood... lol so here is my first obstacle... I'll start witha snippet that works fine and then ask the question...
here we have a query: (not sure why the guy before me built the string this way, maybe for readability? anyway
This puts two columns of data into my sheet... what i want to do is create a function where i can supply arguments that determine what data gets pulled from which db... god i hope that makes sense..hah! problem is in this example we had two columns of data projectID and projectName but that number could change all the time from 2 or 3 data items to maybe 9 or 10 if not more....
hope im explaining myself clearly enough... if not shoot me a reply and ill try to articulate myself better..
here we have a query: (not sure why the guy before me built the string this way, maybe for readability? anyway
Code:
[INDENT]strQuery = "SELECT ProjectName, ProjectID"
strQuery = strQuery + " FROM project"
strQuery = strQuery + " ORDER BY ProjectName"
'Execute the SQL Query and return the results to the temp sheet
With Worksheets("projectNameData").QueryTables.Add(Connection:=strConnection, _
Destination:=Range("A1"), Sql:=strQuery)
'Query does not execute until the refresh command is called
.Refresh
[/INDENT]
hope im explaining myself clearly enough... if not shoot me a reply and ill try to articulate myself better..