Mar 26th, 2006, 07:27 AM
From a VB Form: Invoke a Report (with DataEnvironment) & USING SQL
I am trying to use DataEnvironment1, Connection1 and Command1 with visual basic 6 and produce reports executing SQL commands that use data coming (during run-time) from the user.
A simple example is:
I added a new DataEnvironment1, set the Connection1 and Command1 (using the Properties window) - mean I chose the database (Access) and also, I added a new Report in which I have a text that is bound with the database and also works with the SQL statement of Command1: Select * from ATable where CID = '1'
But in my project, I want '1' to be dynamic, meaning I want the user to write in a textbox (Text1) in a form (Form1) and press a command button (Command1) and this invokes the Report (with : Report.Show )..
Therefore, I want in my SQL statement to join the SQL command with the FORM...
How can I do that???
Mar 26th, 2006, 09:42 AM
Re: From a VB Form: Invoke a Report (with DataEnvironment) & USING SQL
Change the sql statement of command1 to use parameters (ie use Select * From ATable Where CID = prmCID). Set the appropriate properties for the Parameter. The DataEnvironment.Command1 method will now contain a argument for the parameter.
VB code to set the parameter and execute the report
Private Sub cmdShowReport_Click()
If DataEnvironment1.rsCommand1.State = adStateOpen Then
Click Here to Expand Forum to Full Width
Survey posted by VBForums.