Find Next button fails to find records

daveatthewell

New Member
Joined
Jul 28, 2006
Messages
43
I have two membership type databases (they are in no way connected, I mention both for illustrative purposes) Both use a form to input data, the control source for each form is a query and each query updates respective tables. In both databases, there is a Command Button the purpose of which is to find a record based on the member's surname ie a Find button which calls the built in "Find and Replace" dialog. The code generated by Access is identical viz:
Code:
Private Sub cmdFind_Click()

    Me![LastName].SetFocus
    DoCmd.RunCommand acCmdFind

End Sub

In one database the command button works as intended, Displays the built-in Find and Replace dialog and displays the first record found with that surname; clicking the "Next" button (on the dialog) finds the next records (assuming one exists).
On the other database, the Command button brings up the dialog, finds the first record, but refuses to find any further records (which do exist and are spelt correctly with no trailing or leading spaces) displaying the message that "Microsoft Access finished searching the records. The search item was not found". If I close the dialog and click the command button again, then click Find, it finds the next record, but again doesn't find subsequent records. Where is the code for the "Find Next" button on the dialog stored because it's obviously not receiving the search parameters.
Anyone got any thoughts on this one?

BTW including:
Code:
    Screen.ActiveControl.SetFocus
which I believe is generated with a Find Next Command button has no effect.

Regards Dave
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I have found out what the problem was. For one reason or another I made the last statement on the On_Current event for the form in question switch the focus to another control - every time the Find routine found the first record, the Forms Current Event triggered and the focus switched away from the LastName control and therefore Find Next was never going to work. Doh!

Sitting in the corner with a pointy hat on.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top