By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

DoCmd.FindRecord ends at last record

P: 6
hello,

I have a code like:
Expand|Select|Wrap|Line Numbers
  1. Private sub button1_Click()
  2. DoCmd.FindRecord Me.fieldname.Value, acStart, , acSearchAll, , , False
  3. end sub
  4.  
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.
Oct 1 '09 #1
Share this Question
Share on Google+
8 Replies


Plater
Expert 5K+
P: 7,872
I don't know what object you are using, but DataReader can only be searched through once.
Oct 1 '09 #2

P: 6
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
Oct 1 '09 #3

Plater
Expert 5K+
P: 7,872
So this is VBA? I will move it then.
Oct 1 '09 #4

NeoPa
Expert Mod 15k+
P: 31,266
Thanks Plater :)

Try :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.FindRecord(FindWhat:=Me.FieldName, _
  2.                       Match:=acEntire, _
  3.                       Search:=acSearchAll, _
  4.                       OnlyCurrentField:=acCurrent, _
  5.                       FindFirst:=True)
Please let us know if this works for you.
Oct 1 '09 #5

P: 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.
Oct 2 '09 #6

NeoPa
Expert Mod 15k+
P: 31,266
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.
Oct 2 '09 #7

P: 6
I couldn't get the docmd.findrecord to work like I wanted so I implemented my own search over the recordset.

Thanks for your suggestions.
Oct 5 '09 #8

NeoPa
Expert Mod 15k+
P: 31,266
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.
Oct 5 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.