Search error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    #1

    Search error

    hi all,
    I m using this code for searching with respect to Reg No:

    Code:
    ADODC1.Recordset.Find "Reg No = " & txtREG
    But it is not searching
    Thanx
  • jrtox
    New Member
    • Sep 2007
    • 89

    #2
    Originally posted by Ali Rizwan
    hi all,
    I m using this code for searching with respect to Reg No:

    Code:
    ADODC1.Recordset.Find "Reg No = " & txtREG
    But it is not searching
    Thanx
    Try This One:

    Adodc1.CommandT ype = adCmdText
    Adodc1.RecordSo urce = "SELECT * FROM TableName WHERE FieldName='" & txtREG.Text & "'"
    adodc1.refresh

    Regards
    ervin

    Comment

    • Ali Rizwan
      Banned
      Contributor
      • Aug 2007
      • 931

      #3
      Originally posted by jrtox
      Try This One:

      Adodc1.CommandT ype = adCmdText
      Adodc1.RecordSo urce = "SELECT * FROM TableName WHERE FieldName='" & txtREG.Text & "'"
      adodc1.refresh

      Regards
      ervin
      Thanxxxxxxxxxxx xxxxx Ervin
      And this Thanx for answering my all questions at time.

      Comment

      • Ali Rizwan
        Banned
        Contributor
        • Aug 2007
        • 931

        #4
        Originally posted by jrtox
        Try This One:

        Adodc1.CommandT ype = adCmdText
        Adodc1.RecordSo urce = "SELECT * FROM TableName WHERE FieldName='" & txtREG.Text & "'"
        adodc1.refresh

        Regards
        ervin
        Hello Ervin,
        This code is doing nothing.
        I have a database named Information
        Table Name is Info
        And i have to search about Name and Reg No both.
        Please solve the problem
        Thanx

        Comment

        • hariharanmca
          Top Contributor
          • Dec 2006
          • 1977

          #5
          Originally posted by Ali Rizwan
          Hello Ervin,
          This code is doing nothing.
          I......Thanx
          Try the below code.
          [CODE=vb]
          Adodc1.CommandT ype = adCmdUnknown
          Adodc1.RecordSo urce = "SELECT * FROM TableName WHERE strFieldName Like '" & txtREG.Text & "' or numberFieldName = " & val(txtREG.Text )
          Adodc1.Refresh
          Adodc1.Recordse t.MoveFirst
          MsgBox " No. Record : " & Adodc1.Recordse t.RecordCount[/CODE]

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            I wouldn't bother with the Val() function, since you're placing it into a string anyway.

            Comment

            • hariharanmca
              Top Contributor
              • Dec 2006
              • 1977

              #7
              That's sample for number field and string field (he is not clear with where clause). Not exactly to the search value..

              The sample like below.

              [CODE=vb] Adodc1.RecordSo urce = "SELECT * FROM TableName WHERE strFieldName Like '" & txtStringValue. Text & "' or numberFieldName = " & val(txtNumericV alue.Text)[/CODE]

              Comment

              • Ali Rizwan
                Banned
                Contributor
                • Aug 2007
                • 931

                #8
                Thanks all of you for helping me a lot.
                Thans again.

                Comment

                • Ali Rizwan
                  Banned
                  Contributor
                  • Aug 2007
                  • 931

                  #9
                  Originally posted by hariharanmca
                  Try the below code.
                  [CODE=vb]
                  Adodc1.CommandT ype = adCmdUnknown
                  Adodc1.RecordSo urce = "SELECT * FROM TableName WHERE strFieldName Like '" & txtREG.Text & "' or numberFieldName = " & val(txtREG.Text )
                  Adodc1.Refresh
                  Adodc1.Recordse t.MoveFirst
                  MsgBox " No. Record : " & Adodc1.Recordse t.RecordCount[/CODE]
                  Hello hari,
                  This code works but the problem is that after searching the record we can only see the searched record in the grid.
                  I want to see other records too.
                  Thanx

                  Comment

                  • hariharanmca
                    Top Contributor
                    • Dec 2006
                    • 1977

                    #10
                    Originally posted by Ali Rizwan
                    Hello hari,
                    This code works but the problem is that after searching the record we can only see the searched record in the grid.
                    I want to see other records too.
                    Thanx
                    You want to search like

                    If you type 'A' then the recordset should select name starts with 'A'?
                    Can you explain properly?

                    Comment

                    • Ali Rizwan
                      Banned
                      Contributor
                      • Aug 2007
                      • 931

                      #11
                      Originally posted by hariharanmca
                      You want to search like

                      If you type 'A' then the recordset should select name starts with 'A'?
                      Can you explain properly?
                      Yeah this one and this too

                      Suppose i have following records in name field
                      ABC
                      ABD
                      BCD
                      BBG
                      XYZ

                      Now using your code i select ABC to search
                      Now the DataGrid only shows the record ABC but not ABD,BCD,BBG.XYZ
                      I want to show all of records.

                      Thanx

                      Comment

                      • hariharanmca
                        Top Contributor
                        • Dec 2006
                        • 1977

                        #12
                        Originally posted by Ali Rizwan
                        Yeah this one and this too
                        ............... .
                        Purpose of where clause is to select particular record then why you want to display all records?

                        Comment

                        • Ali Rizwan
                          Banned
                          Contributor
                          • Aug 2007
                          • 931

                          #13
                          Originally posted by hariharanmca
                          You want to search like

                          If you type 'A' then the recordset should select name starts with 'A'?
                          Can you explain properly?
                          Hello Hari,
                          One more problem occuring.
                          When i enter a Field name with a space then it show an error and does not search.
                          I have search for field Reg No it does not search.
                          Thanks

                          Comment

                          • Ali Rizwan
                            Banned
                            Contributor
                            • Aug 2007
                            • 931

                            #14
                            Originally posted by hariharanmca
                            Purpose of where clause is to select particular record then why you want to display all records?
                            I have labels too connected with same database which show only one record at a time.
                            When i search the required record shows in labels but i dont want to do the same thing to DGrid. i want to show all records here. But the required record will focused automatically when i searched.
                            Thanx

                            Comment

                            • hariharanmca
                              Top Contributor
                              • Dec 2006
                              • 1977

                              #15
                              Originally posted by Ali Rizwan
                              Hello Hari,
                              One more problem occuring.
                              User Trim() function for the text box like...

                              [CODE=vb]Trim(txtStrValu e.Text)[/CODE]

                              You have to explain what is that error?

                              Comment

                              Working...