Finding a particular record in a Grid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • squrel
    New Member
    • Jan 2008
    • 143

    Finding a particular record in a Grid

    Hello everybody..
    I have a form to find the records according to contact name and pono... in tht i have a find button tht by clicking has to point to my main grid (frmpo) and show the pono which has been selected in the find form or contact name.. it has to point to the first finding option in tht grid..
    i dont knw how to use pointer from this frmfind form to the frmpo and find the selected pono and contactname
    plz help... thank u
  • squrel
    New Member
    • Jan 2008
    • 143

    #2
    I need help here... anybody can give me some infomation abt doing this..
    thanks

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      Add a ".Bas" module in your Project and Declare a Public Variable MyPONo in the module. Once you do this, MyPONo is available throughout the project..

      In the Search Form, Populate MyPONo with the Selected number.
      and in Calling form, Loop through the grid and Find the PONo..

      Regards
      Veena

      Comment

      • squrel
        New Member
        • Jan 2008
        • 143

        #4
        i already have tht .Bas module in my project... but is thr any way i can do this thing only in my frmfind form..
        wld u plz check my code... i had added the grid over here and was working properly but now i have to remove tht grid and point the selected pono and contact to the main gird... in tht case i added the find button to my form.. but whtever code i m putting in tht its not working
        thank u



        Sub FindPurchaseOrd ers(FieldName As String, fieldValue As String)

        Dim sQuery As String
        If FieldName = "CONTACT" Then
        sQuery = "select TxPoHdr.PoNo,Tx PoHdr.YY as Year,convert(Va rChar(20), TxPoHdr.PoDate, 6) As PoDate,Msunits. UnitNm,MsVendor s.VendorNm,TxPo Hdr.AmendNo as AmendNo,TxPoHdr .Ind,Txpohdr.Co ntact From TxPoHdr,Msunits ,MsVendors Where TxPoHdr.Unitid = Msunits.Unitid And TxPoHdr.VendorI d = MsVendors.Vendo rId And TxPoHdr.Ind <>'8' and contact like '" & fieldValue & "%' order by txpohdr.pono"

        ' Adodc1.Connecti onString = pStrConnectionS tring
        ' Adodc1.RecordSo urce = sQuery
        ' Adodc1.Refresh
        ' Set MSHFlexGrid1.Da taSource = Adodc1
        ' Set MSHFlexGrid1.Re cordset = Adodc1.Recordse t
        ' Adodc1.Refresh
        ' MSHFlexGrid1.Co lWidth(1) = 500
        ' MSHFlexGrid1.Co lWidth(2) = 700
        ' MSHFlexGrid1.Co lWidth(3) = 1100
        ' MSHFlexGrid1.Co lWidth(4) = 3500
        ' MSHFlexGrid1.Co lWidth(5) = 3500
        ' MSHFlexGrid1.Co lWidth(6) = 1000
        ' MSHFlexGrid1.Co lWidth(7) = 500
        ' MSHFlexGrid1.Co lWidth(8) = 2000
        ' MSHFlexGrid1.Re fresh
        ' Call GridCol

        End If

        If FieldName = "PO_NUMBER" Then
        sQuery = "select TxPoHdr.PoNo,Tx PoHdr.YY as Year,convert(Va rChar(20), TxPoHdr.PoDate, 6) As PoDate,Msunits. UnitNm,MsVendor s.VendorNm, TxPoHdr.AmendNo as AmendNo,TxPoHdr .Ind,TxPoHdr.Co ntact From TxPoHdr,Msunits ,MsVendors Where TxPoHdr.Unitid = Msunits.Unitid And TxPoHdr.VendorI d = MsVendors.Vendo rId And TxPoHdr.Ind <>'8'and PoNo = " & fieldValue

        ' Adodc1.Connecti onString = pStrConnectionS tring
        ' Adodc1.RecordSo urce = sQuery
        ' Adodc1.Refresh
        ' Set MSHFlexGrid1.Da taSource = Adodc1
        ' Set MSHFlexGrid1.Re cordset = Adodc1.Recordse t
        ' Adodc1.Refresh
        ' MSHFlexGrid1.Co lWidth(1) = 500
        ' MSHFlexGrid1.Co lWidth(2) = 700
        ' MSHFlexGrid1.Co lWidth(3) = 1100
        ' MSHFlexGrid1.Co lWidth(4) = 3500
        ' MSHFlexGrid1.Co lWidth(5) = 3500
        ' MSHFlexGrid1.Co lWidth(6) = 1000
        ' MSHFlexGrid1.Co lWidth(7) = 500
        ' MSHFlexGrid1.Co lWidth(8) = 2000
        ' MSHFlexGrid1.Re fresh
        ' Call GridCol

        End If

        End Sub
        Private Sub CMDCLOSE_Click( )
        Unload Me
        End Sub


        Private Sub cmdFind_Click()

        End Sub


        Private Sub Combo1_Change()
        Text1.Text = ""
        End Sub

        Private Sub Combo1_Click()

        Text1.Text = ""
        'Set MSHFlexGrid1.Da taSource = Nothing
        'MSHFlexGrid1.C lear
        'MSHFlexGrid1.R efresh

        End Sub



        Private Sub Text1_Change()
        If Combo1.ListInde x = 0 Then
        '
        FindPurchaseOrd ers "CONTACT", Text1.Text

        Else
        If IsNumeric(Text1 .Text) Then
        FindPurchaseOrd ers "PO_NUMBER" , Text1.Text
        End If

        End If
        Text1.Refresh
        End Sub

        'Public Function GridCol()
        ' Dim i As Single
        ' Dim j As Single
        '
        ' For i = 1 To MSHFlexGrid1.Ro ws - 1
        '
        ' If Val(Trim(MSHFle xGrid1.TextMatr ix(i, 7))) = 0 Then
        ' MSHFlexGrid1.Ro w = i
        '
        ' For j = 1 To 8
        ' MSHFlexGrid1.Co l = j
        ' MSHFlexGrid1.Ce llBackColor = &HFFC0FF
        ' Next
        '
        ' ElseIf Val(Trim(MSHFle xGrid1.TextMatr ix(i, 8))) = 1 Then
        ' MSHFlexGrid1.Ro w = i
        '
        ' For j = 1 To 8
        ' MSHFlexGrid1.Co l = j
        ' MSHFlexGrid1.Ce llBackColor = &HFFFFFF
        ' Next
        '
        ' ElseIf Val(Trim(MSHFle xGrid1.TextMatr ix(i, 7))) = 9 Then
        '
        ' MSHFlexGrid1.Ro w = i
        ' For j = 1 To 8
        ' MSHFlexGrid1.Co l = j
        ' MSHFlexGrid1.Ce llBackColor = &HFFFFC0
        ' Next
        '
        ' End If
        ' Next
        'End Function
        '

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          You have commented the code of Refreshing the Grid Control..
          Un-comment that part and check..

          Regards
          Veena

          Comment

          • squrel
            New Member
            • Jan 2008
            • 143

            #6
            Hi Veena..
            I knw i have commented the code... coz i dont need the grid in my frmfind... it was working perfectly when was not commented.... i need to point to the main gird which is frmpo... have problem with tht... is there anyway i can do frm my cmdFind button and point to the selected pono or contact name in my main grid? my question is tht?

            Comment

            • QVeen72
              Recognized Expert Top Contributor
              • Oct 2006
              • 1445

              #7
              Hi,

              Yes, you can..

              In your Code, Instead of using:
              MSHFlexGrid1

              Just change it to :
              frmMain.MSHFlex Grid1

              Regards
              Veena

              Comment

              • squrel
                New Member
                • Jan 2008
                • 143

                #8
                OK.. I wil try tht.. thank u very much

                Comment

                Working...