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

Insert SQL statement on DECommand from a form... 1

Status
Not open for further replies.

wacks

Programmer
Sep 10, 2001
58
US
how can i insert the SQL statement generated from a form to a Data Environment Command?!?

let's say i have DataEnvironemnt1, Command1, and a strSQL from Form1 ...

i tried inserting this syntax
DataEnvironement1.Command1.CommandText = strSQL
but it gives me an error "Invalid Qualifier"...

i need your help! thnx
 
does anyone knows how to answer my question?
 
Hi wacks,

The code you want is:

DataEnvironement1.commands("Command1").CommandText = strSQL

You'll need to close any open recordset and then reopen it after you change it, something like this:

if DataEnvironement1.rsCommand1.State=adstateopen then dataenvironment1.rscommand1.close

DataEnvironement1.commands("Command1").CommandText = strSQL

dataenvironment1.command1

 
HISCorsair

hey! i tried your suggestion but still it doesnt work. it says Failed Getting Rowset(s) from current data source error

* i put your command at onActivate event of the DataReport and i even tried it on the command button of the form, but it didnt work... where do i have to insert the command?

* i leave the CommandText blank so i can insert the strSQL, but it didnt work also...

please give me a step-to-step procedure re this matter..please... thnx so much... my boss needs this report ASAP


thnx so much
 
You'll need to put that code in the procedure that calls the Data Report I think, not in the Data Report itself. Because the Data Report is bound, you'll need the commandtext set before the Data Report gets opened.

If you still get that error after moving the code, you might try putting this before that code I gave you, assuming DataReport1 is the name of your Data Report:

set DataReport1.datasource=nothing

Then after the code I gave you, put:

set Datareport1.datasource=dataenvironment1

Then have the code that actually loads the Data Report.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top