Select Record AFTER Search

tarcona

Registered User.
Local time
Today, 10:11
Joined
Jun 3, 2008
Messages
165
Open Add/Edit form. And if you use the search function click on the Contacts tab and type in Smith in Last Name. What I want is when the user types the last name and finds the last name, I want that record that matches that search word to be selected.

When a record is selected it is highlighted....so essentially I want the record highlighted when a record is found. Instead of the first record being highlighted. So in the example, when you type in Smith, I want the second record that has John Smith highlighted instead of the first.

Please look at my database if it is somehow confusing:
 

Attachments

the subform that contains the records you want highlighted has a filter applied to it. that needs to be fixed, otherwise it will ruin your efforts here. Secondly, you probably aren't going to want to dynamically search after every key is pressed. that is too tough. Instead, use the search button that is located underneath where you type the last name.

for this, either use searchforrecord, or gotorecord, or maybe even filter and filteron = true. Any of these will work just fine for the subform.
 
I have:

Me.ClientInformation_Subform.SetFocus
DoCmd.GoToRecord , , acGoTo, strSQL

But it doesnt work. I tried, acLast and it works perfectly but this doesnt.
 
I have:

Me.ClientInformation_Subform.SetFocus
DoCmd.GoToRecord , , acGoTo, strSQL

But it doesnt work. I tried, acLast and it works perfectly but this doesnt.
The "strSQL" section has to be congruent with a "WHERE" clause, like the ones found in queries. That is probably what is wrong. Here is an example of that section of the syntax:
Code:
"[fieldname] = '" & criteriastring & "'"
 
I just tried that and it didnt work.

My string variable is: l_strAnd

And this is what I put:

Me.ClientInformation_Subform1.SetFocus
DoCmd.GoToRecord , , "[First Name] = '" & l_strAnd & "'"

Any other ideas?
 

Users who are viewing this thread

Back
Top Bottom