Saturday, February 25, 2012

Between [Enter the Start Date] And [Enter the End Date])

Hi all can you help me please, I need the users to be able to enter in a date for a self generating report. Usually I use the @.Enter_Date but I need them to be able to enter a start date and a end date
But when I run this query SQL gives me an error message Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'Enter the Start Date'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'Enter the End Date'.

What should use in place of BETWEEN [Enter the Start Date] And [Enter the End Date]??

SELECT [Main Table].[IR Number], [Main Table].Date, [Main Table].Inspector, [Main Table].Area, [Main Table].Violation, [Main Table].[Violation Type], [Main Table].Loss, [Main Table].[Loss Type], [Main Table].Employee, [Main Table].Action, [Main Table].[Action Type], [Main Table].Notes
FROM [Main Table]
WHERE ((([Main Table].Date) Between [Enter the Start Date] And [Enter the End Date]))
ORDER BY [Main Table].[IR Number]Is it possible for your front end to ask for the inputs? Then you could just supply both dates as parameters to a sproc.|||My front end is an Access 2003 an MDB, I need to change it to a ADP but Jet SQL and MSSQL dont exactly speak the same language|||Sure they do, I use pass-through queries all the time.

I use code to get my parameter values from the user, and then change the
QueryDef.SQL on the fly.

Start a new query, then go to Query -> Sql Specific -> Pass-Through

Then for your SQL
Execute YourSproc "paramvalue1", "paramvalue2"|||YESSSS

SELECT [IR Number], Date, Inspector, Area, Violation, [Violation Type], Loss, [Loss Type], Employee, Action, Notes, [Action Type]
FROM dbo.[Main Table]
WHERE (Date BETWEEN @.StartDate AND @.EndDate)
ORDER BY [IR Number]

I'M SO HAPPY IT WORKS FINALLY HOOOORRAAAAYYYYY

HAPPY DANCE!!!!!!!!!!!!!!!!!!!!!!

No comments:

Post a Comment