Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transfer variable from Form to Data Environment ,SQL Command

Status
Not open for further replies.

groner

Programmer
May 18, 2002
23
RO
If I have one Form and two ComboBox ( 1 and 2)
The user select from Combo1 one name and from Combo2 select one age .
Line code it's something like this :
Dim varName , varAge as String
varName = Combo1.Text
varAge = Combo2.Text
Now the program create a SQL Statment for loading data from a Database .
SQL = "SELECT * FROM table WHERE name LIKE '*" & varName & "*' AND age LIKE '*" & varAge & "*'"
Question :
How can I transfer the varName and varAge in SQL Statment in Data Environment , Command statment ?
I want to create one Data Report witch print just information witch store in database and user selected by using ComboBox's in Form .
I hope do you get me !
Thank's for every sugestion .
 
well first off you need to declare name as a string, without anything there vb is looking at it as a variant type. ----------------
Joe
 
Hey I ran across that problem myself. What you want to do is access the Command in the DataEnvironment. Assuming that:
1. You have created a DataEnvironment
2. You have established a connection
3. You have added a command (in the properties select the SQL part).

Now the Data Reports are linked to the DataEnvironment so that's why you need to send the SQL to the Command part.

In whatever form you have the combo boxes and want to send the SQL statement to the DataEnvironment...you type

DataEnvironment1.Commands.Item(1).CommandText = " Your SQL Statement"

This assumes that you have one command in the DataEnivronment (hence Item is 1). After you enter this in, just run DataReport1.Show and that should do it.

If you have any other questions just post it and I'll do my best.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top