Help with Search and/or FindNext

dtburdick

Registered User.
Local time
Today, 12:04
Joined
Oct 29, 2002
Messages
33
This is killing me... and so is my customer.

I have set my application options default Find/Replace behavior to General Search. It works fine the first time the user does it. Thereafter, however, it reverts back to Look In: <specific field> and Match: Whole Field.

Is it possible to make it so Access ALWAYS defaults to:

Look In: Search
Match: Any Part of Field

I tried creating my own FindRecord and FindNext buttons, but that was a disaster because you lose focus when you click the button to execute that code, so it always goes to the first record. I've tried setting focus to various things, SendKeys, Macros, etc.

How do you call FindNext from code?

Thanks for any help.
 
dt,

Use the Search facility here and look for "Search". This has been covered
a lot of times here.

Also look at the Sample Database forum.

Wayne
 
I did that and found one that will work in a pinch, but will ultimately be too slow as data gets poopulated, but for the time being it will do.

If anyone has an answer I'd still like it because the built in "Search" capability is faster and closer to what my customer wants.

:) just saw I mistyped populated, but will leave it for others to get a laugh at.

FYI, this is the solution I'm using for now.

Thanks for your assistance.
 
Bear with me here dtburdick,

In case this hasn't been considered. (I'd be surprised).
A public variable, set to the control to be searched on.

Option Compare Database
Option Explicit
Dim fSearch As Control

Private Sub cmdFind_Click()
Set fSearch = txtArtist
fSearch.SetFocus
DoCmd.FindRecord txtArtistSearch
End Sub

Private Sub cmdFindNext_Click()
fSearch.SetFocus
DoCmd.FindNext
End Sub

This is a rough idea, showing how one can maintain focus on the control, without explicitly naming it every time.
Ideally, I wouldn't want it hardcoded in "cmdFind" either.

Another thought. loop through all relevant controls, assuming they can be defined. This will result in a general search.

Private Sub cmdFind_Click()

Dim ctl As Control

For Each ctl In Me.Controls
If Left(ctl.Name, 3) = "txt" And ctl.Name <> "txtEntry" Then
Set fSearch = ctl
fSearch.SetFocus
DoCmd.FindRecord txtEntry
End If
Next

End Sub

Hope this offers some ideas.
Good Luck, either way!
 
I use this technique...
Code:
Public Function bFindRecord() As Boolean

    'set focus back to where it was before user clicken on command button that invoked this function.
    'Relevant Command buttons' OnClick Event are set to "=bFindRecord()"

    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdFind

    End Function
 

Users who are viewing this thread

Back
Top Bottom