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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with VB6 Report

Status
Not open for further replies.
Aug 26, 2002
5
US
Hello All,

I am still having difficulty passing a variable from a form into the SQL statement located within a DataEnvironment.

I have a form with various defined Text Boxes (txtUser, txtComputer, etc.) what I would like to do is get the text that is input by the tech in that form and pass it into the SQL statement (essentially saying "SELECT * FROM Table1 WHERE User = "txtUser.text" AND Computer = "txtComputer.text"). This would then be retrieved by a Data Report.

Is this even remotely possible or am I beating a dead horse?

Any help you could provide would be appreciated.

Tom Lively
 
Hi !

Usually, I write this in data environment :
"SELECT * FROM Table1 WHERE User = ?

and for the code in form I use this code :

dataenvironment1.command1 txtuser.text

This code will pass the parameter from txtuser to the sql statement, and for the case like you have (2 conditions), I never try it before, but I think you can try by using child command :)

Hope this can help you

Regards,
Agrina
 
Hi,

try using ado recordset for the report's data source.

Dim rs as New ADODB.Recordset
rs.Open "Your SQL", YourActiveConnectionVariable

Set YourReportName.DataSource=rs
YourReportName.Show

Set the report's TextBoxes DataField properties to the fields that query returns and that's it.

Hope this helps, Mangro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top