Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Referring to a text box in a sql statement within a view


Message #1 by "Tom Baggett" <ictom4u@h...> on Thu, 17 Jan 2002 19:39:10
what is the syntax needed in the WHERE portion of a View SQL statment that 

will refer to a textbox on form - in an Access query it was [forms]!

[frmName].[textbox].value. I'm converting to a Access Data Project that 

has a SQL Server database and that syntax no longer works. Really stuck - 

please help.
Message #2 by "Darin Wray" <darin@r...> on Thu, 17 Jan 2002 13:52:03 -0600
I'd create a stored procedure with a parameter...



for example...



create procedure "sp_SalesByDate"

@BeginningDate smalldatetime

@EndingDate smalldatetime

As

SELECT Sales, Employee, Date

FROM dbo.Sales

WHERE Date between @BeginningDate and @EndingDate

ORDER BY Employee



Now that you have the stored procedure...set it as the forms recordsource

that you want to use to view your result set.  On the same tab that you use

to set the recordsource (Data) there is a setting called Input Parameters.

This is where you designate what value should be passed to the stored

proc/recordsource to display the results that you want.  In my

example...let's say I had another form that had 2 text boxes for a beginning

date and ending date, called frmBetweenDates.    In my input parameter for

my form that I want to use to review the results from...I'd type:



@BeginningDate smalldatetime = forms!frmBetweenDates!txtBeginningDate,

@EndingDate smalldatetime = forms!frmBetweenDates!txtEndingDate



Whatever dates I have in my frmBetweenDates text boxes would be passed to

the stored procedure, which is my recordsource for my form that I'll use to

see my results.



Hope this helps!

Darin









----- Original Message -----

From: "Tom Baggett" <ictom4u@h...>

To: "Access" <access@p...>

Sent: Thursday, January 17, 2002 7:39 PM

Subject: [access] Referring to a text box in a sql statement within a view





> what is the syntax needed in the WHERE portion of a View SQL statment that

> will refer to a textbox on form - in an Access query it was [forms]!

> [frmName].[textbox].value. I'm converting to a Access Data Project that

> has a SQL Server database and that syntax no longer works. Really stuck -

> please help.




>




  Return to Index