anyone here to help using the code
hello everybody,
its really amazing dat no one is ready to help me over my problems. perhaps its due to lack of my code well. tell me what is the right code of saving record of multiple entries using flex grid and also tell me how to add row for next record after entry one record in the flexgrid.
i m using the following code for flexgrid but its not save code coz i dont know how to write exact code for saving on exact location in database
Dim db As New ADODB.Connection
Dim tb As New ADODB.Recordset
Dim recset As New Recordset
Private Sub cmdadd_Click()
If cmdadd.Caption = "&Add New" Then
cmdadd.Caption = "&Save"
txtename.SetFocus
'cmddelete.Caption = "&Cancel"
recset.Open "Select max(srno) as c from emp_personal", db
tb.AddNew
clearfields
txtsrno = recset!c + 1
recset.Close
Else
tb("SrNo") = txtsrno.Text
tb("Employee_Name") = txtename.Text
tb("Father_Name") = txtfname.Text
tb("nic") = masknic.Text
tb("brname") = cmbbrname.Text
tb("dob") = dtpdob.Value
tb("religion") = txtreligion.Text
tb("idmark") = txtmark.Text
tb("paddress") = txtaddress.Text
tb("photo") = txtphoto.Text
tb("appletter") = txtapletter.Text
tb("appdate") = dtpltrdate.Value
tb.Update
MsgBox "Record Successfully Entered", vbInformation, "Cantt Board Office, D.I.Khan"
cmdadd.Caption = "&Add New"
End If
clearfields
End Sub
Private Sub Form_Load()
Set db = New ADODB.Connection
Set tb = New ADODB.Recordset
With db 'database connectivity with access
.Provider = "microsoft.jet.oledb.4.0"
' .CursorLocation = adUseClient
.Open App.Path & "\SBook.mdb"
End With
Dim sSQL As String
sSQL = "select * " & _
" from emp_personal"
' Open the tb table.
With tb
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open sSQL, db
End With
dtpdisp.Enabled = False
txtdetail.Enabled = False
txtresult.Enabled = False
Call headings
clearfields
End Sub
Private Sub headings()
With grid
.Col = 0
.ColWidth(0) = 500
.ColWidth(1) = 3500
.ColWidth(2) = 1450
.ColWidth(3) = 1400
.ColWidth(4) = 1700
.Row = 0
.TextMatrix(.Row, 0) = "S.No"
.TextMatrix(.Row, 1) = "Station Name"
.TextMatrix(.Row, 2) = "From Date"
.TextMatrix(.Row, 3) = "To Date"
.TextMatrix(.Row, 4) = "Total Period Served"
End With
End Sub
Private Sub grid_KeyPress(KeyAscii As Integer)
txtenter.Text = txtenter.Text & Chr(KeyAscii)
txtenter.SelStart = 1
txtenter.Move grid.CellLeft + grid.Left, grid.CellTop + grid.Top, grid.CellWidth, grid.CellHeight
txtenter.Visible = True
txtenter.SetFocus
End Sub
Private Sub grid_LeaveCell()
If txtenter.Visible = False Then
Exit Sub
End If
grid.Text = txtenter
txtenter.Visible = False
txtenter.Text = ""
End Sub
thnx in advance
|