Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning 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 10th, 2007, 02:05 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 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
 
Old December 10th, 2007, 08:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

well.. you have all the code.. what problem have that code???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old December 11th, 2007, 05:19 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

dear gbianchi,,

thnq for replying well actually i mmaking a project of service record of employee, in which the employee transfer record is also included.so i want to use flexgrid for transfer record in which the employee served on different stations. so da problems are

1. how to save da data using flexgrid in access database under the name of cmd_add_click()
2. the data consists of more than 2 rows of one person.
3. the fields are, "station", "fromdate", "todate", "duration"

thnq again for keeping me in ur solutions.
 
Old December 11th, 2007, 09:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Still don't understand your problem, why you just take out the data of the grid and store it in the database??? you have problem with the code of taking data out of the grid??

did you try google??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old December 12th, 2007, 01:20 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

dear qbianchi,,

well once again i try to understand u wats problem i have.

1. i have entered da data in flexgrid which comprises more than two rows now i want to save it in access database. how to save it? bcoz is it possible to save da data consisting more dan two rows under one employee number? if it is plz tell me da code or adjust the code in my coding? it is not possible saving data of more than one rows in flexgrid den plz tell me the alternate way of the same situation.?

2. when i enter data in flexgrid n i want that next row should appear right after da end of first row n so on.plz tell also abt it.

thnq





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM
disable forum code within [code] blocks? nikolai Forum and Wrox.com Feedback 0 October 23rd, 2003 07:52 PM





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