Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 disjointed code

Author  Topic 

slimjen
Yak Posting Veteran

61 Posts

Posted - 2012-07-17 : 01:04:52
All, I have an Access 2003 front end link to tables in Sql Server 2008. I have three different separate divisions within this database. I have pass thru queries based on information in these divisions. I want to use a form for users to select a division, select a date range and output the results to an excel file to the user’s desktop or any folder they wish. I created a form that has unbound forms to select a division, year and two date ranges for beginning month end month. I am having trouble with putting the code together. I can get the code to run separately, but not together:

case "ShortTerm" = "qrySTReports"
case "LongTerm"="qryLTReports"
case "Term"="qryAllTerm"
stDocName = "qrySTReports"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.OutputTo acOutputTable, "qrySTReports", acFormatXLSX


Dim strWhere As String
strWhereY="[cboYear]
strWhere = "[MonthProcessed] Between " & Format(Me.txtBeginDate, "\#mm\/dd\/yyyy\#) & " And " & Format(Me.txtEndDate, "\#mm\/dd\/yyyy\#")


I am trying to put this together based on multiple criteria on the form. Does anyone do anything similar; please help.
Thanks

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2012-07-17 : 02:21:21
You must ask the right question.

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-17 : 10:05:17
see this. the query formed should be like below

http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -