DoCmd.FindRecord ends at last record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • internetintern
    New Member
    • Oct 2009
    • 6

    DoCmd.FindRecord ends at last record

    hello,

    I have a code like:
    Code:
    Private sub button1_Click()
    DoCmd.FindRecord Me.fieldname.Value, acStart, , acSearchAll, , , False
    end sub
    but the problem is that the command stops searching at the last record. so the records before the current record are not searched. I thought with acSearchAll it should search the entire record list.

    I need some help here.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I don't know what object you are using, but DataReader can only be searched through once.

    Comment

    • internetintern
      New Member
      • Oct 2009
      • 6

      #3
      I am working with Ms access forms and the code above is a control for a button. I don't want to start searching from the first record (this works fine). the docs show that the above code should search from the current record to the end of the set, then start from the beginning to the current record. in the end all records should be searched. I don't know why this doesn't work for me.

      I may have posted this question in the wrong place

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        So this is VBA? I will move it then.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          Thanks Plater :)

          Try :
          Code:
          Call DoCmd.FindRecord(FindWhat:=Me.FieldName, _
                                Match:=acEntire, _
                                Search:=acSearchAll, _
                                OnlyCurrentField:=acCurrent, _
                                FindFirst:=True)
          Please let us know if this works for you.

          Comment

          • internetintern
            New Member
            • Oct 2009
            • 6

            #6
            yes it is vba, thanks for moving it; i tried to figure out how to do it.

            thanks NeoPa for the code. it begins always from the first record. also it would always find the first hit. My code begins from the next record after the current record and should cycle through the entire record set back to the current record just like the Access 'Find Next'.

            I'm still trying to find out why it ends at the last record instead of continuing from the first record back to the current record.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32656

              #7
              I looked in Help & it says little more than listing the available values for the parameters. Essentially, it's not a lot of ...

              Anyway. I suggest your next step is to experiment with the three parameters (Match, Search & FindFirst) to see if you can come up with a combination that does it as you need. Unfortunately, it is sometimes necessary to do some research (in this case trial & error) before being able to understand things correctly.

              Comment

              • internetintern
                New Member
                • Oct 2009
                • 6

                #8
                I couldn't get the docmd.findrecor d to work like I wanted so I implemented my own search over the recordset.

                Thanks for your suggestions.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32656

                  #9
                  That seems like a shame. Sorry I couldn't be more help.

                  A self-made search should only be noticeably slower if the number of records is quite large though.

                  Comment

                  Working...