More Accurate Filter Than DoCmd.ApplyFilter Like

MCCDOM

Registered User.
Local time
Today, 22:27
Joined
Oct 30, 2014
Messages
84
Hi There,

I have a combo box that you select a name in and the text boxes below get populated with the relevant record. To achieve this I have got the following bit of code on the after update event of the combo box 'cboNameLookup':
Code:
DoCmd.ApplyFilter "", "[StaffID] Like ""*"" & [Forms]![frmPasswordLookup]![cboNameLookup] & ""*""", ""
Now this works absolutely fine for the majority of all searches except for one that I have come across. The text boxes are populating with the wrong persons data. Now when I have a look at the datasheet of results that are being returned I notice they all contain the number 5 which is the StaffID of the user I am searching for. Normally it chooses the correct option but for some reason the person I want is at the bottom of the list.

Is there some code that will find only the number 5 ID and not ones containing 5 please?

Kind regards,

Dom
 
If Staff ID is a (hopefully) unique number then don't use the wildcards ("*"), assuming you only want to find one record.
 
Thanks a lot Minty that has worked a treat.
 

Users who are viewing this thread

Back
Top Bottom