CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Using a variable in sql query

Print topic Send  topic

Author Message
swilson


Posts: 84
Posted: 10/16/2005, 5:40 PM

This works:
SELECT *
FROM Color_Codes
WHERE Model LIKE '182S'
AND Right(BegSer,4) < Right('18280308',4)
AND Right(EndSer,4) > Right('18280308',4)

But I want to replace the '182S' with '{Model}' which would represent AircraftModel.Text and '18280308' with '{SERIAL_NUMBER} which would be AircraftSERIAL_NUMBER.Text.

I tried setting the Parameter Source type to either URL (which it is not) or Form. Neither works.

Where am I going wrong??
_________________
It continues to amaze me, how often the solutions to seemingly complex problems are so very simple.
View profile  Send private message
Stan
Posted: 10/17/2005, 6:58 AM

Hi

The form's controls don't exist when datasource Select statement is executed. So you can't use them as parameter source in such cases. You should pass these parameters by some other way (URL, for example). But i can wrongly understand flow of your app.

Stas
swilson


Posts: 84
Posted: 10/17/2005, 7:15 AM

Stan,

First, thank you so much for your contributions to the forum. It is so very helpful to me.

The flow of this app is a search form that produces the URL parameters for a record form on the same page. The record form includes text boxes and list box controls that has source data from other tables. I need a couple of the listbox controls to be limited by an SQL query and parameter from the form.

The record form updates a record from the Aircraft table. When one aircraft is displayed from the search, you can update information about that specific plane in the record form. For color selection, I only want to show choices in the listbox that pertain to that aircraft's model type - which is a control, AircraftModel.Text on the same form.

Please offer your advice on the best way to do this. I am presently disapointed to learn I cannot use the forms controls to pass a parameter to the SQL statement. Boy did I ever try!
_________________
It continues to amaze me, how often the solutions to seemingly complex problems are so very simple.
View profile  Send private message
Stan
Posted: 10/17/2005, 8:26 AM

Looks like your task can be solved by custom code only. You can try the following trick

1.Define for listbox 2 expression parameters {Model} and {SERIAL_NUMBER} with type text and value 1 (or any other number)
2.Then select Before Build Select event for list box and add custom code
3.Find the parameters declaration into the code for determine their names. You can found names a shade lower in the ListBox Initialize DataSource Block. They will looks like Expr{SomeId}, for example Expr15.
4. Add the following code to the event

 Expr{id}.Value = item.Model.Value
 Expr{id}.Value = item.SERIAL_NUMBER.Value

regards,
Stan
swilson


Posts: 84
Posted: 10/17/2005, 10:05 AM

Thanks again Stan!

Your solution makes sence to me. I am still strugling with setting up the {Model} parameter correctly, getting:
error BC30451: Name 'Model' is not declared.
AircraftData.Expr65 = TextParameter.GetParam(Model, CObj(1))
or
error BC30201: Expression expected.
AircraftData.Expr65 = TextParameter.GetParam({Model}, CObj(1))

To set the Parameter in your instruction 1. above, I cliked the ... for Data Source of the Listbox, then cliked the + button, Condition Type:Parameter, Field Name: Model (from the drop-down populated from Color_Codes), Type: Text, Condition: Equals, Parameter Source: Model (And I tried {Model}), Type: Expression, Use Default: 1.

I should understand this better by now, please, tell me how the {Model} and {Serial_Number} parameters are defined, per your item 1. I understand the rest fine and I can't see why this won't work.

THANKS Stan!

_________________
It continues to amaze me, how often the solutions to seemingly complex problems are so very simple.
View profile  Send private message
swilson


Posts: 84
Posted: 10/17/2005, 10:13 AM

It did not fail what I used the Parameter Source AircraftModel.Text instead of Model.

It seems to work Stan. It almost seems to good to be true as I labored over this solution for hours and hours. THANKS!
_________________
It continues to amaze me, how often the solutions to seemingly complex problems are so very simple.
View profile  Send private message
swilson


Posts: 84
Posted: 10/17/2005, 10:26 AM

Stan, I am so very grateful! Thanks again!
_________________
It continues to amaze me, how often the solutions to seemingly complex problems are so very simple.
View profile  Send private message
robn

Posts: 70
Posted: 01/06/2006, 2:58 AM

Hi I've been trying to use your code for a problem I have with a list box filter. I want the list box to display items depending on the value of a hidden field within the same form. But I'm getting an error with the code (using ASP not .NET). I've set the parameter controls and have created custom code on the list box before build select event. But I get an error message

Quote :
Object doesn't support this property or method: 'tblQualcall.expr104'

the code looks like this

tblQualcall.expr104 = tblQualcall.Catlink.Value  
tblQualcall.expr115 = tblQualcall.Catlink.Value

Where tblQualcall is the name of the form.

Any help would be greatly appreciated

thanks
Rob
View profile  Send private message
swilson


Posts: 84
Posted: 01/07/2006, 3:27 PM

I use dot net, but try:

Expr104.value = Item.Catlink.Value  
Expr115.value = Item.Catlink.Value

Best,
Steve
_________________
It continues to amaze me, how often the solutions to seemingly complex problems are so very simple.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.