Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. selecting a data in flexgrid

selecting a data in flexgrid

Scheduled Pinned Locked Moved Visual Basic
helpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GaryKoh
    wrote on last edited by
    #1

    hello may i know how do i select a data in flexgrid and then show it in another form please help me im using vb6 thank you Gary

    S 1 Reply Last reply
    0
    • G GaryKoh

      hello may i know how do i select a data in flexgrid and then show it in another form please help me im using vb6 thank you Gary

      S Offline
      S Offline
      superwinsock
      wrote on last edited by
      #2

      'This is on the main form Dim strCustData(0 To 12) As String Dim lngClientId As Long Dim bytCount As Byte With grdClients If .TextMatrix(.Row, 0) = "" Or .TextMatrix(.Row, 1) = "N/A" Then MsgBox "Please Select a Record" Exit Sub Else lngClientId = .TextMatrix(.Row, 0) For bytCount = 0 To UBound(strCustData, 1) strCustData(bytCount) = .TextMatrix(.Row, bytCount + 1) Next bytCount End If End With Call Load(frmUpdate) With frmUpdate .MP_ClientDetails lngClientId, strCustData .Show vbModal End With ---------------------------------------------- 'This is a function in the receiving page Public Sub MP_ClientDetails(lngClientId As Long, strCustData() As String) Dim bytCount As Byte For bytCount = 0 To UBound(strCustData, 1) txtCustDetails(bytCount).Text = strCustData(bytCount) Next bytCount exit sub Hope this helps!

      G 1 Reply Last reply
      0
      • S superwinsock

        'This is on the main form Dim strCustData(0 To 12) As String Dim lngClientId As Long Dim bytCount As Byte With grdClients If .TextMatrix(.Row, 0) = "" Or .TextMatrix(.Row, 1) = "N/A" Then MsgBox "Please Select a Record" Exit Sub Else lngClientId = .TextMatrix(.Row, 0) For bytCount = 0 To UBound(strCustData, 1) strCustData(bytCount) = .TextMatrix(.Row, bytCount + 1) Next bytCount End If End With Call Load(frmUpdate) With frmUpdate .MP_ClientDetails lngClientId, strCustData .Show vbModal End With ---------------------------------------------- 'This is a function in the receiving page Public Sub MP_ClientDetails(lngClientId As Long, strCustData() As String) Dim bytCount As Byte For bytCount = 0 To UBound(strCustData, 1) txtCustDetails(bytCount).Text = strCustData(bytCount) Next bytCount exit sub Hope this helps!

        G Offline
        G Offline
        GaryKoh
        wrote on last edited by
        #3

        hii will this also work if i have this module?? Public Function AutoComplete(sTextbox As TextBox, sFlexGrid As MSFlexGrid, sDB As Database, sTable As String, sField As String) As Boolean On Error Resume Next Dim sCounter As Integer Dim OldLen As Integer Dim sTemp As Recordset AutoComplete = False If Not sTextbox.Text = "" Then OldLen = Len(sTextbox.Text) Set sTemp = sDB.OpenRecordset("SELECT * FROM " & sTable & " WHERE " & sField & " LIKE '" & sTextbox.Text & "*'", dbOpenDynaset) If Not sTemp.RecordCount = 0 Then If sTemp.EOF = True And sTemp.BOF = True Then MsgBox "Not Matching Records", vbInformation, "Error" Else sTemp.MoveFirst sFlexGrid.Clear sFlexGrid.FormatString = "Book Name |ISBN |Author |Book In-Store" Do While Not sTemp.EOF sFlexGrid.AddItem sTemp.Fields(0).Value sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 1) = sTemp.Fields(1).Value sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 2) = sTemp.Fields(2).Value sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 3) = sTemp.Fields(3).Value sTemp.MoveNext Loop End If If sTextbox.SelText = "" Then sTextbox.SelStart = OldLen Else sTextbox.SelStart = InStr(sTextbox.Text, sTextbox.SelText) End If sTextbox.SelLength = Len(sTextbox.Text) AutoComplete = True Else sFlexGrid.Clear End If End If End Sub this must be available in it. so this means i put the code in the Flexgrid or the form_load? im not really sure please tell me thank you Gary

        S 1 Reply Last reply
        0
        • G GaryKoh

          hii will this also work if i have this module?? Public Function AutoComplete(sTextbox As TextBox, sFlexGrid As MSFlexGrid, sDB As Database, sTable As String, sField As String) As Boolean On Error Resume Next Dim sCounter As Integer Dim OldLen As Integer Dim sTemp As Recordset AutoComplete = False If Not sTextbox.Text = "" Then OldLen = Len(sTextbox.Text) Set sTemp = sDB.OpenRecordset("SELECT * FROM " & sTable & " WHERE " & sField & " LIKE '" & sTextbox.Text & "*'", dbOpenDynaset) If Not sTemp.RecordCount = 0 Then If sTemp.EOF = True And sTemp.BOF = True Then MsgBox "Not Matching Records", vbInformation, "Error" Else sTemp.MoveFirst sFlexGrid.Clear sFlexGrid.FormatString = "Book Name |ISBN |Author |Book In-Store" Do While Not sTemp.EOF sFlexGrid.AddItem sTemp.Fields(0).Value sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 1) = sTemp.Fields(1).Value sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 2) = sTemp.Fields(2).Value sFlexGrid.TextMatrix(sFlexGrid.Rows - 1, 3) = sTemp.Fields(3).Value sTemp.MoveNext Loop End If If sTextbox.SelText = "" Then sTextbox.SelStart = OldLen Else sTextbox.SelStart = InStr(sTextbox.Text, sTextbox.SelText) End If sTextbox.SelLength = Len(sTextbox.Text) AutoComplete = True Else sFlexGrid.Clear End If End If End Sub this must be available in it. so this means i put the code in the Flexgrid or the form_load? im not really sure please tell me thank you Gary

          S Offline
          S Offline
          superwinsock
          wrote on last edited by
          #4

          Hi Gary Could you elaborate on what it is exactly you are trying to do? Is your question... When I select a row of info on a grid, how do I populate another page with the selected data?? Cliff

          G 1 Reply Last reply
          0
          • S superwinsock

            Hi Gary Could you elaborate on what it is exactly you are trying to do? Is your question... When I select a row of info on a grid, how do I populate another page with the selected data?? Cliff

            G Offline
            G Offline
            GaryKoh
            wrote on last edited by
            #5

            well the module is to select all the data from DB when the textBox is fill the flexgrid will show the data in the flexgrid so.. i want to know is that when i select the row of data using the code u gave me it will show in other form, right? then where should i put the code in the flexgrid? module? or in the form_load? actually you can ignore the module i send to you and thank you Cliff Gary

            S 1 Reply Last reply
            0
            • G GaryKoh

              well the module is to select all the data from DB when the textBox is fill the flexgrid will show the data in the flexgrid so.. i want to know is that when i select the row of data using the code u gave me it will show in other form, right? then where should i put the code in the flexgrid? module? or in the form_load? actually you can ignore the module i send to you and thank you Cliff Gary

              S Offline
              S Offline
              superwinsock
              wrote on last edited by
              #6

              Hey Gary Ok... Once you have populated your flexgrid: You will select a row of data by clicking on the flexgrid row. Then(just as example) you have a command button called cmdENTER. When you have selected a row and then click cmdENTER, you put the selected rows information in an array called strCustData. It has been dimentioned to (0 to 12) because there are 13 columns in my row. 'So this code will go in the same form as your selected flexgrid 'Copy this code into VB, it will be easier to read Private sub cmdENTER_Click() Dim strCustData(0 To 12) As String Dim lngClientId As Long Dim bytCount As Byte With grdClients 'This just checks if a valid record was selected If .TextMatrix(.Row, 0) = "" Or .TextMatrix(.Row, 1) = "N/A" Then MsgBox "Please Select a Record" Exit Sub Else 'Sets my variable to the first column's value of the selected row lngClientId = .TextMatrix(.Row, 0) 'here we assign the rows values to our array For bytCount = 0 To UBound(strCustData, 1) strCustData(bytCount) = .TextMatrix(.Row, bytCount + 1) Next bytCount End If End With 'Now we call our next form where you want the selected row's data ' to be displayed 'Load the form Call Load(frmUpdate) With frmUpdate 'Then in frmUpdate create a Public Sub call MP_ClientDetails 'and here we call that Sub and pass through our array 'strCustData) .MP_ClientDetails lngClientId, strCustData .Show vbModal End With End Sub 'Here is the code for that Public Sub which should be in frmUpdate Public Sub MP_ClientDetails(lngClientId As Long, strCustData() As String) Dim bytCount As Byte 'Here we assign the values from our Array into the textboxes on 'frmUpdate (Obviously this could be changes to a grid or ??) For bytCount = 0 To UBound(strCustData, 1) txtCustDetails(bytCount).Text = strCustData(bytCount) Next bytCount End Sub I really suck at explaining things but hope this helps a little. If confusion reigns just tell me and I will try explain in a different way Regards Cliff

              G 1 Reply Last reply
              0
              • S superwinsock

                Hey Gary Ok... Once you have populated your flexgrid: You will select a row of data by clicking on the flexgrid row. Then(just as example) you have a command button called cmdENTER. When you have selected a row and then click cmdENTER, you put the selected rows information in an array called strCustData. It has been dimentioned to (0 to 12) because there are 13 columns in my row. 'So this code will go in the same form as your selected flexgrid 'Copy this code into VB, it will be easier to read Private sub cmdENTER_Click() Dim strCustData(0 To 12) As String Dim lngClientId As Long Dim bytCount As Byte With grdClients 'This just checks if a valid record was selected If .TextMatrix(.Row, 0) = "" Or .TextMatrix(.Row, 1) = "N/A" Then MsgBox "Please Select a Record" Exit Sub Else 'Sets my variable to the first column's value of the selected row lngClientId = .TextMatrix(.Row, 0) 'here we assign the rows values to our array For bytCount = 0 To UBound(strCustData, 1) strCustData(bytCount) = .TextMatrix(.Row, bytCount + 1) Next bytCount End If End With 'Now we call our next form where you want the selected row's data ' to be displayed 'Load the form Call Load(frmUpdate) With frmUpdate 'Then in frmUpdate create a Public Sub call MP_ClientDetails 'and here we call that Sub and pass through our array 'strCustData) .MP_ClientDetails lngClientId, strCustData .Show vbModal End With End Sub 'Here is the code for that Public Sub which should be in frmUpdate Public Sub MP_ClientDetails(lngClientId As Long, strCustData() As String) Dim bytCount As Byte 'Here we assign the values from our Array into the textboxes on 'frmUpdate (Obviously this could be changes to a grid or ??) For bytCount = 0 To UBound(strCustData, 1) txtCustDetails(bytCount).Text = strCustData(bytCount) Next bytCount End Sub I really suck at explaining things but hope this helps a little. If confusion reigns just tell me and I will try explain in a different way Regards Cliff

                G Offline
                G Offline
                GaryKoh
                wrote on last edited by
                #7

                hi cliff thank you for your help it really work thank you very much

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups