I am a newbie to VB6 and need some help with the following please.
I have created a simple form where a datagrid is bound to a adodc control and the connection string is set by its properties. The information from the access 2000 database shows in the Datagrid o.k.
The problem is that the fields are not in the correct order and I wish the user to be able to click on the column headers and be able to sort asc or desc.
First, you'll need to move your report source string value for the ADODC control inside your form code. This way you can change it on the fly when people want to sort, etc.
There are 2 ways you can change what columns have what value.
1- how you select columns by the connection string
2- from the properties of the datagrid, specifically the data field value
As for the sorting, you'll have to have a function on the click command of the datagrid. Then you'll have to:
1- check to see if the user is clicking on the header row (I'm not sure if this is row 0 or if it has a special designation to it)
2- if it is the header, just re-establish the value of the report source string and refresh the adodc object.
'sql connection example
Adodc1.ReportSource = "Select * From Table Order By X ASC"
As long as the data source for your grid is Adodc1, it will update itself when the Adodc1.RecordSource changes.