You have to first Close the rs.Command Object, then set the Command Text of the command object to teh new SQL, then reexecute the
command object which recreates the recordset. THen it would not hurt to rebind the list..
If DE.rsCommand.state=1 then de.rscommand.close
de.commands("Comamnd").CommandText="MyNewSQL"
de.Command
Set List.RowSource=DE
Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Want to know more? Check out the MSDN at msdn.microsoft.com or the Microsoft Knowledge Base at support.microsoft.com
This posting is provided AS IS, with no warranties, and confers no rights.
--------------------
>Subject: DataEnvironment SQL change at run time
>Date: Thu, 22 Aug 2002 22:21:30 +1000
>Lines: 20
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>Newsgroups: microsoft.public.vb.database
>NNTP-Posting-Host: 202.47.52.151
>Path: cpmsftngxa10!tkmsftngp01!tkmsftngp12
>Xref: cpmsftngxa10 microsoft.public.vb.database:85387
>X-Tomcat-NG: microsoft.public.vb.database
>I am fairly new to VB and a real greenhorn on DataEnvironmet, but I am
>learning...
>I am programmatically changing the CommandText property to a different SQL
>query but it does not reflect on the connected DataList control at run time.
>It just stays with the data from the initial CommandText as it shows in the
>properties at design time. I have tried things like:
> Me.DataList2.ReFill
> Me.DataList2.Refresh
>or
> deTZ.rscomNames.Requery
>but nothing seems to work.
>Maybe I am trying a completely wrong approach here.
>Any ideas?
>Meini