data save problem from flex grid
dear friends.
i m new in vb6 i have been assigned tasks of making small database for entering record of employee in da following format in flexgrid.
[u]S.No City Name from date to date total service</u>
1. lahore 12/2/1990 11/1/1995
2. dikhan 12/1/1995 15/9/2005
3. karachi 16/9/2005 24/11/2006
4. dikhan 25/11/2006 --------
the above data is only for one employee and i want to save date like dis, in data base using flexgrid but wats exact coding plz, help me out, to solve da problem,
below is da code for saving records but i dont know wat is da code for saving above data
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
thanq in advance
|