Sir i have written a code in command1_click i want if user click on save button all the grid data should store in MR table
rs1.Fields("item_code") = Grd.TextMatrix(1, 1)
rs1.Fields("productname") = Grd.TextMatrix(1, 2)
rs1.Fields("unit") = Grd.TextMatrix(1, 3)
these line are working fine but i want to store all the grid data
either it should be Grd.textmatrix(2,2),grd.textmatrix(3,2) ...so and so it should store data column wise it should store all the column data in a MR table for one it should one record for 2 row it should create another record in a table and so and so
Private Sub Command1_Click()
Dim item_code, product_name, unit As String
Dim strSql As String
Dim nm As String
' Debug.Assert False
' On Error GoTo err
Set rs1 = New Recordset
rs1.Open " SELECT * FROM MR ", con, adOpenDynamic, adLockOptimistic
rs1.AddNew
rs1.Fields("Dept_name") = Combo1.Text
rs1.Fields("job_no") = Text1.Text
If IsNumeric(Text2.Text) Then
rs1.Fields("cost_centre") = CLng(Text2.Text)
rs1.Fields("emp_name") = Text3.Text
rs1.Fields("del_point") = Text4.Text
rs1.Fields("del_time") = CStr(MaskEdBox1)
If IsDate(DTPicker2.Value) Then
rs1.Fields("del_date") = DTPicker2.Value
rs1.Fields("sug_vendor") = Text7.Text
If IsDate(DTPicker1.Value) Then
rs1.Fields("mr_date") = DTPicker1.Value
rs1.Fields("manager") = Text13.Text
rs1.Fields("qty") = FlexGridEditor.Value
rs1.Fields("item_code") = Grd.TextMatrix(1, 1)
rs1.Fields("productname") = Grd.TextMatrix(1, 2)
rs1.Fields("unit") = Grd.TextMatrix(1, 3) Call InsertIntoMR
' strSql = "insert into MR values('" & cItemCode & "','" & product_name & "','" & unit & "')"
' strSql = strSql & "'" & Val(Grd.TextMatrix(Grd.Row, 1)) & "',"
' Debug.Print strSql
' con.Execute (strSql)
' rs1.Fields("Unit").Value = unit
' rs1.Fields("item_code") = Trim(Grd.TextMatrix(Grd.Row, Grd.Col) & "")
' rs1.Fields("item_code").Value = Trim(Grd.TextMatrix(Grd.Row, cItemCode) & " ")
' rs1.Fields("productname") = Trim(Grd.TextMatrix(Grd.Row, Grd.Col) & "")
' rs1.Fields("unit") = Trim(Grd.TextMatrix(Grd.Row, cUnit) & "")
End If
End If
End If
rs1.Update
MsgBox Trim(Grd.TextMatrix(1, 1))
MsgBox "Commit", vbInformation, Me.Name
rs1.Close
Exit Sub
'err: MsgBox "Error in Command1_Click()" & vbCrLf & err.Number & vbCrLf & err.Description
End Sub