Hello all!

I have a flexgrid and everytime a user would click in a cell to edit it, an error occurs
"Run time error 5 "Invalid procedure call or argument""

Here is my code:

'simple sub routine to fake the edits
Private Sub EditFlexGridCell(PassedText As String, Optional CpBoard As Boolean)
EditingCell = True 'set a global notifier that we are editing a cell
With txtEdit 'with the txtedit textbox, do the following
'first set the undotext to the current grid position's text in case
'the user hits escape or doesn't change it
UndoText = CheckFlexGrid.TextMatrix(CheckFlexGrid.Row, CheckFlexGrid.Col)
If PassedText = "" Then 'see if any text was incoming like from the clipboard
.Text = CheckFlexGrid.Text
.SelStart = 0
.SelLength = Len(.Text) 'highlight the text in the cell
ElseIf PassedText = "DEL" Then 'if the user pressed delete, then erase the text
.Text = ""
Else
.Text = PassedText 'if text was coming from the clipboard, stick it in here now
If CpBoard = True Then
.SelStart = Len(.Text) 'highlight it too
Else
.SelStart = 1
End If
End If
.SetFocus (where the error occurs)
'set the focus to the textbox so if the user enters text, it shows up in the textbox
End With
End Sub

Thanks!!!

Silly me...the textbox 'Visible' property was set as false!

But I do have a new question:

As I close the flexgrid I want to be able to save what has been changed...the code I am using is

Public Function Read_Values_From_Grid() As String

Dim i, j
j = 0
With MyMainRecordset
'move to the first record
.MoveFirst
i = 1
Do While i <= .RecordCount
j = 0
'loop through the grid contents and update the recordset with the new values
Do While j < .Fields.Count
If .Fields(j).Name <> "FName" Then
If Not IsNull(CheckFlexGrid.TextMatrix(i, j)) Then
'if the grid value is null, set the field value to "" empty string
.Fields(j).Value = CheckFlexGrid.TextMatrix(i, j)
Else
.Fields(j).Value = ""
End If
End If
j = j + 1
Loop
.MoveNext 'move to the next record
i = i + 1
Loop
If .EOF Then
Exit Function
End If
.Update 'actually issues the update command
End With

Read_Values_From_Grid_ClickErr:
frmMain.Show
Public Function Read_Values_From_Grid() As String
On Error GoTo Read_Values_From_Grid_ClickErr:
Dim i, j
j = 0
With MyMainRecordset
'move to the first record
.MoveFirst
i = 1
Do While i <= .RecordCount
j = 0
'loop through the grid contents and update the recordset with the new values
Do While j < .Fields.Count
If .Fields(j).Name <> "FName" Then
If Not IsNull(CheckFlexGrid.TextMatrix(i, j)) Then
'if the grid value is null, set the field value to "" empty string
.Fields(j).Value = CheckFlexGrid.TextMatrix(i, j)
Else
.Fields(j).Value = ""
End If
End If
j = j + 1
Loop
.MoveNext 'move to the next record
i = i + 1
Loop
If .EOF Then
Exit Function
End If
.Update 'actually issues the update command
End With


It gets an error:
File cannot be updated.

The error inwhich the line occurs is:
.Fields(j).Value = CheckFlexGrid.TextMatrix(i, j)

Any ideas?

Thanks much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.