I have an application where a Datagrid is bound to an ADO datacontrol.
I have typed in the relevant SQL into the RecordSource of the ADO control and the Datagrid fills up as required.
However, at runtime, I need to change the SQL statement depending on circumstances.
When I do this, the grid contents don't change at all.
Can I dynamically alter the Recordsource porperty?
The code is below ..
The grid is called grdmembership.
The datacontrol is called AdoMembership
grdMembership.ClearFields
AdoMembership.RecordSource = "SELECT Board_ID, Membership_ID FROM tblMembership WHERE Board_ID LIKE '" & Trim(Working.BoardID) & "%'"
grdMembership.ReBind
grdMembership.Refresh
29-02-2008 at 03:05 PM
|
stickleprojects Level: Moderator Registered: 09-09-2002 Posts: 1030
Re: Channging datasource on ADO
Hi,
The answer is "Yes" you can alter the source SQL.
What problems have you found?
[Edited by stickleprojects on 05-03-2008 at 03:28 PM GMT]
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
Hi, Thanks for your reply.
The problem is that, when I change the Recordsource, I can't get the grid to reflect the changes.
It still has the data in which was retrieved from the Recordource held by the data control when the form loaded.
It looks like I need to explicitly tell it to refresh its data, but I have tried various combinations of Refresh and Rebind without any joy!
05-03-2008 at 05:08 PM
|
stickleprojects Level: Moderator Registered: 09-09-2002 Posts: 1030
Re: Channging datasource on ADO
HI
Ensure you are using the latest SP (There's some dodgy stuff about the datagrid in the later sps for visual studio)
grdMembership.datasource = adoMembership should do it
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
I think I have cracked it now.
I hadn't set the 'DataChanged' property of the grid to True - hence it never went looking for the new data.
Did this and it all sprang to life.