Searching for multiple data (1 Viewer)

fergcu

Registered User.
Local time
Today, 00:16
Joined
Jun 23, 2007
Messages
23
Hi,
I currently have an employee database - all info is currently in one table.
I am wanting to create a search box in my form which allows me to search for multiple bits of information. ie. I would like to be able to type in either a first name, surname, full name, or employee id number (for example), press enter, and for it to display the results (either by going to the first that it finds, and me then clicking find next, or by displaying all found in an index so that you double click the one that you want - i am not too fussed... the main issue is getting the search box to look in multiple fields).

I currently have the following code:

Code:
Private Sub cmdFind_Click()

DoCmd.ShowAllRecords
DoCmd.GoToControl ("Surname")
DoCmd.FindRecord Me!txtIDFind
'If FindRecord = True Then
'Exit Sub
'End If
DoCmd.GoToControl ("EIN")
DoCmd.FindRecord Me!txtIDFind
'If FindRecord = True Then
'Exit Sub
'End If
DoCmd.GoToControl ("forename")
DoCmd.FindRecord Me!txtIDFind

End Sub

(ignore the notes - they were trial and error for something else).

Currently, when i press find, this code will find the first of anything - ie i time in Frank and the first Frank will appear (unless someones surname begins with Frank). What i can't seem to do is get it to progress to the next record if i press a find next button.

I have also tried the following code, but it only works if i put in an EIN number:

Code:
Private Sub Findall_Click()

DoCmd.ShowAllRecords
DoCmd.GoToControl ("ein")
DoCmd.FindRecord Me!txtIDFind, acStart, acAll, True


Any thoughts? I think i'm probably looking at this in completely the wrong way.

Oh, also i am quite new to VB, so please forgive any silly questions that i am likely to ask!

Kind regards,

Fergus.
 

ColinEssex

Old registered user
Local time
Today, 00:16
Joined
Feb 22, 2002
Messages
9,116
This Quicksearch code in this demo database will search multiple fields, the results are in a listbox and then when you select the required record from the listbox, the full data is shown.

You'll need to tweak it to fit your fieldnames of course. It's in A2000

Col
 

Attachments

  • QuicksearchExample2000.zip
    16.3 KB · Views: 262

fergcu

Registered User.
Local time
Today, 00:16
Joined
Jun 23, 2007
Messages
23
excellent, thanks Colin - i'll have a play with that and see what i can do.

Will let you know how I get on.

Ferg
 

fergcu

Registered User.
Local time
Today, 00:16
Joined
Jun 23, 2007
Messages
23
Colin, just to let you know that the form you sent me was perfect... made a few additions to allow searching for more than one field at a time, and its spot on, so thank you.
 

Users who are viewing this thread

Top Bottom