Link to home
Start Free TrialLog in
Avatar of especht
especht

asked on

Edit or Add Record to a MSHFLexGrid

I currently have a form that has fields, plus a mshflexgrid using VB 6. The fields are controlled by one ado recordsource and the mshflexgrid has another ado recordsource that is based on current values in the fields. (For example, the first field is a text box that holds the id of 1; therefore, the flexgrid displays the record(s) in that source which are equal to 1.

Here is my problem
=============================
How can I add a new value or edit a value on the mshflexgrid? Currently when I click on the flexgrid, it just highlights the current cell.

I hope I have provided enough information. Please let me know if you need anything specific.

especht
Avatar of especht
especht

ASKER

Here is a screen-shot and a little more explanation if it helps.

http://www.geocities.com/jvwd/screen_shot.html

TIA,
especht
The Problem is that MsFlexGrid is Read-Only. There are ways to get around this and to edit your data. One way you can do is this. In the keydown event of FlexGrid you can write code that will enter new data into that cell , this will require you additional processing for charecters like backspace key and others so they won't be represented in another way. And after you enter that data you would issue and update of the recordset or execute an sql command or you can have a floating textbox which you can assign a value to. Then Update The Grid. I'll post the code for that.
With FlexGrid
If .MouseRow = 0 Then Exit Sub
    Combo3.Clear
    iRow = .Row: iCol = .Col
    Combo3.Left = .CellLeft + .Left
    Combo3.Top = .CellTop + .Top
    Combo3.Width = .CellWidth
    Combo3.Visible = True
end With
now you have that value in a textbox all you have to do is issue and update.
ASKER CERTIFIED SOLUTION
Avatar of wsh2
wsh2

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 especht

ASKER

wsh2,

Thanks for the info. That works great, but how can I get this to work with a recordset displayed in the grid?

especht
In the FG2_LeaveCell procedure add code to update your Recordset.. <smile>.


Avatar of especht

ASKER

Thank you! And thanks all for their time and input.

especht
thanks!