Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Query Wizard Cannot Be Used To Edit This Query | Excel Discussion (Misc queries) | |||
How to do Edit Query from Import External Data. | Excel Discussion (Misc queries) | |||
why does edit query button not open query | Excel Discussion (Misc queries) | |||
Excel new/edit External Data Query hangs | Excel Discussion (Misc queries) | |||
Problem with MS Query - can't edit query | Excel Discussion (Misc queries) |