Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 28th, 2007, 02:37 AM
Authorized User
 
Join Date: Jul 2006
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to naveed77 Send a message via Yahoo to naveed77
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
save and update data problems using flex grid naveed77 Beginning VB 6 0 December 6th, 2007 03:57 AM
VS Flex Grid Version 7 abdulqadirpk VB Components 0 December 27th, 2006 07:16 AM
flex grid [email protected] General .NET 0 January 12th, 2006 01:18 AM
Flex grid in VBA - Excel raj_phoenix Excel VBA 7 February 1st, 2005 07:40 AM
flex grid entry jady VB Databases Basics 1 September 29th, 2004 11:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.