We help IT Professionals succeed at work.

Editing MSHFlexgrid

mscala
mscala asked
on
Hi

I am using ADO to display information in a mshflexgrid. I am using this grid because a normal msflexgrid doesn't seem to work with and ADO Datacontrol. I am trying to edit a specific row in the grid before it is displayed. I am using the following code:

    For i = 1 To cnt
        Adodc1.Recordset.EditMode
        Adodc1.Recordset.Fields("No") = i
        Adodc1.Recordset.Update
        Adodc1.Recordset.MoveNext
    Next
cnt  is a counter which calculates the number of rows in the recordset.
It complains about EditMode, what am I doing wrong, how do I go about editing a specific column.

Another thing is how can you change the recordsource in the ADODC. It is set to "Select * from Table* but at a later stage I want to change that sql statement to something else, how do I do this? It doesn't seem to change the recordsource no matter what I try.


Please can someone help
Thanks!
Comment
Watch Question

TimCotteeHead of Software Services
CERTIFIED EXPERT

Commented:
You don't need to specify .EditMode as assuming that the cursortype is adOpenStatic or adOpenKeyset and that the locktype is NOT adLockReadonly on the ADO data control then you can edit the recordset's values. As to changing the recordsource, you have to do that by:

ADODC1.RecordSource = "Select * From MyNewTable"
ADODC1.Refresh

This changes the sql statement for the recordset and refreshes the control.

Author

Commented:
TimCottee

Hi, I am getting the following error when I refresh the adodc.

In the recordsource of the adodc : "Select * from Quotes"

IN my code where I want to change the recordsource I have the following:
    Adodc1.RecordSource = "Select * From Quotes Where TenderNo = """ & SrchStr & """Order by Amount"
    Adodc1.Refresh

On refresh it gives me the error:
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Can you help please?
Thanks
TimCotteeHead of Software Services
CERTIFIED EXPERT

Commented:
Use single quotes rather than double


   Adodc1.RecordSource = "Select * From Quotes Where TenderNo = '" & SrchStr & "' Order by Amount"
   

Author

Commented:
TimCottee

Perfect, you're a hero.
Thanks so much!

Just one thing, I am ordering my Amount. What I would like is for the amount to be ordered from highest to lowest, instead it is ordering from lowest to highest.

???
Head of Software Services
CERTIFIED EXPERT
Commented:
Then use "Order By Amount Desc" the default for order by is (Asc)ending but if you specify (Desc)ending it will do it the other way around.

Author

Commented:
Thanks very much for your help
Much Appreciated

Explore More ContentExplore courses, solutions, and other research materials related to this topic.