Link to home
Start Free TrialLog in
Avatar of mscala
mscala

asked on

Editing MSHFlexgrid

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!
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of mscala
mscala

ASKER

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
Use single quotes rather than double


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

ASKER

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.

???
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mscala

ASKER

Thanks very much for your help
Much Appreciated