LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Edit Data Query Programmically?

Squid,

If 25 is all the worksheets, you could use

For Each sh in Activeworkbook.Worksheets
varAcct = sh.Name
...
Next sh

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Squid" wrote in message
...
Yes, I could do that (wow this was actually pretty easy).

But what is the best way to cycle through the 25
worksheets? I get a run-time error 91 using the following:

For i = 1 to 25

varAcct = ActiveSheet.Name

<- Code -

ActiveSheet.Next.Select
Next i


-----Original Message-----
So can you not just plug variables into the SQL string

like so

varAcct = "5105"
varDate1 = "20031231"
varDate2 = "20041231"
sSQL= "SELECT GLPJD.ACCTID, GLPJD.JRNLDATE, " & _
"GLPJD.JNLDTLDESC, GLPJD.JNLDTLREF, " & _
"GLPJD.TRANSAMT" & _
"FROM GLPJD GLPJD" & _
"WHERE (GLPJD.ACCTID='" & varAcct & "')

AND " & _
" (GLPJD.JRNLDATE" & varDate1

& " AND " & _
" GLPJD.JRNLDATE<=" & varDate2

& ")" & _
"ORDER BY GLPJD.JRNLDATE"

and then pass sSQL to the query?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Squid" wrote in

message
...
The SQL from Microsoft query is the following:
SELECT GLPJD.ACCTID, GLPJD.JRNLDATE, GLPJD.JNLDTLDESC,
GLPJD.JNLDTLREF, GLPJD.TRANSAMT
FROM GLPJD GLPJD
WHERE (GLPJD.ACCTID='5105') AND (GLPJD.JRNLDATE20031231
And GLPJD.JRNLDATE<=20041231)
ORDER BY GLPJD.JRNLDATE

I have a separate worksheet for each ACCTID. The
worksheet is named as the ACCTID. So in the above

example
the worksheet is named 5105.


-----Original Message-----
What is the query code like?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Squid" wrote in
message
...
I have a workbook with 25 worksheets. Each worksheet
represents a different general ledger bucket. I

have an
ODBC read-only link to my accounting software. Is it
possible to create code to alter the microsoft query
design. In this case I am selecting 4 fields and

would
like to run some code to alter the date criteria the
query
is using.

TIA

Mike


.



.



 
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
Query Wizard Cannot Be Used To Edit This Query Carl Excel Discussion (Misc queries) 6 October 17th 06 09:59 PM
How to do Edit Query from Import External Data. Excel General Questions Excel Discussion (Misc queries) 1 July 10th 06 10:35 AM
why does edit query button not open query needlemaker Excel Discussion (Misc queries) 0 June 29th 06 03:18 PM
Excel new/edit External Data Query hangs Melissa Excel Discussion (Misc queries) 0 April 19th 06 07:44 PM
Problem with MS Query - can't edit query jarems Excel Discussion (Misc queries) 2 December 12th 05 09:42 AM


All times are GMT +1. The time now is 09:01 AM.

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"