selecting a data in flexgrid
-
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
'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!
-
'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!
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
-
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
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
-
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
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
-
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
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
-
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