Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

to save data in flexgrid

Status
Not open for further replies.

akshita

Programmer
Mar 26, 2002
25
0
0
IN
hi,

i want to save the data in the database which i enter in flexgrid.i want that as soon as flexgrid_leavecell event is invoked its saves the data .i am using ado

the coding of my leavecell event is:::

Private Sub flxgrid_LeaveCell()
If Not IsNull(txtedit.Text) Then
'user typed an entry in the text box
flxgrid.TextMatrix(Active_FlxCell.row, Active_FlxCell.col) = txtedit.Text
End If
End Sub

regards
akshita

 
Dear Akshita

Here is a solution for ur problem...hope it helps...
I have a MSFlexGrid, Textbox, Command button...I use the Northwind.mdbDB's employees table to create my recordset.


Option Explicit
Dim con As ADODB.Connection
Dim rsd As ADODB.Recordset
Dim intI As Integer

Private Sub Command1_Click()
If MSFlexGrid1.Row = 0 Then Exit Sub

If Len(Trim(Text1.Text)) <> 0 Then
MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, MSFlexGrid1.Col) = Text1.Text

rsd.Find &quot;EmployeeID = &quot; & MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0), 0, adSearchForward, adBookmarkFirst
rsd.Fields(&quot;LastName&quot;).Value = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
rsd.Fields(&quot;FirstName&quot;).Value = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
rsd.Update
End If
End Sub

Private Sub Form_Load()
Set con = New ADODB.Connection
Set rsd = New ADODB.Recordset

con.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Mahesh\Northwind.mdb;Persist Security Info=False&quot;

If con.State = adStateOpen Then
MsgBox &quot;Connected&quot;
Else
Exit Sub
End If

rsd.CursorLocation = adUseClient
rsd.Open &quot;Select EmployeeID , LastName , FirstName From Employees&quot;, con, adOpenStatic, adLockOptimistic

If Not (rsd.EOF And rsd.BOF) Then
MsgBox rsd.RecordCount
Else
Exit Sub
End If

MSFlexGrid1.Rows = rsd.RecordCount + 1

For intI = 1 To MSFlexGrid1.Rows - 1
MSFlexGrid1.TextMatrix(intI, 0) = rsd.Fields(&quot;EmployeeID&quot;).Value
MSFlexGrid1.TextMatrix(intI, 1) = rsd.Fields(&quot;LastName&quot;).Value
MSFlexGrid1.TextMatrix(intI, 2) = rsd.Fields(&quot;FirstName&quot;).Value
rsd.MoveNext
Next
End Sub

Regards
Mahesh
mshetti@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top