|
-
Passing parameters to a vb6 query, from form?
Hi there,
REALLY stuck on something! Am very new to VB6 and am trying to run a data report, which runs off of an sql query in a data environment. This works fine when i manually enter the required parameters into the sql query, but i cant seem to get the syntax right for the query to read the values in text fields on the form. Any help would be much appreciated.
Im guessing its a similar solution, but i also need to know how to filter the contents of one db combo, based on the selection made in another one on the same form.
Hope this makes sense!
-
Sushi
Got the same problem here. Can anyone help us???
-
Sample of the troubling code?
| Processor | Intel Pentium 4 @ 2800 MHz | Motherboard | ABIT IC7-Max3 | Memory | 2 GB Corsair XMS PC3200 DDR | Graphics | ATI Radeon 9800 Pro | OS/Prog HDD | W.D. Raptor 36GB (10k) SATA | Storage HDD | Seagate 160GB (7200) SATA | Burner | Lite-On 52x24x52 CDRW | DVD-ROM | Lite-On 16x DVD | Sound Card | Philips Acoustic Edge | Speakers | Klipsch ProMedia 2.1 | Flash Media | Lian-Li Flash Media Bay | Display | Dual NEC 22" Flat CRT | Case/PSU | Lian-Li PC-65B w/ Antec 430W | O.S. | MS Windows XP Pro | Printer | Epson Stylus Photo 2200
-
The Solution!
Hi there,
Okay, i have found the answer to this, after much toil and trawling the web!!
In the dataenvironment, you need to add a parameter to the sql statement or to the sql builder. For example in my case this was:
select....................
from......................
where agent_name = ? and supervisor_name = ?...... etc.....
then before you open your datareport, in my case from a command button on the vb6 form, you add something like the following into your code:
The next 3 lines seem to vary slightly between vb versions?? but the idea is to close the sql command if it is open. This enables multiple runs of the same command with varying inputs.
if dataenvironment1.command1.adstateopen = true then
dataenvironment1.command1.close
end if
The next line passes the parameters the space between command1 and datacombo1 is intentional and necessary!!!
Dataenvironment1.command1 datacombo1.text, datacombo2.text
Then open the report
datareport1.show
My parameters came from Datacombo's but if in your case they are coming from text boxes then obviously you would pass text1.text etc.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|