Search /Find Record Textbox

  • Thread starter Keri Jones via AccessMonster.com
  • Start date
K

Keri Jones via AccessMonster.com

I have a form that shows all fields for a single record. On this form is a
textbox named "Find Record". In this text box I want the user to type in a
candidate name to bring up that record, OR they can type in a ssn# to bring
up a record on the same form.

How do I code the textbox to lookup a record based on if they type a ssn#
in the text box OR a candidate name in the same text box?

Thanks,
Keri
 
R

Rick Brandt

Rick said:
If Val(Me.TextBox) = 0 Then
'They typed a SSN
(SSN Search code goes here)
Else
'They typed a name
(Name Search code goes here)
End if

Sorry, the above If-Then logic is obviously backwards.

(Where's that damn coffee pot?)
 
J

John Spencer (MVP)

The lazy way, just search based on the value being in either field.

If you are doing that in a query

Field: SSN
Criteria: Forms![FormName]![TextBoxControlName]

Field: CandidateName
Criteria:
CriteriaLine2: Forms![FormName]![TextBoxControlName]

SQL statement
SELECT ...
FROM ...
WHERE CandidateName = Forms![FormName]![TextBoxControlName] OR
SSN = Forms![FormName]![TextBoxControlName]

If the two fields are indexed this will be fast. The difference in searching
one field versus two fields will be undetectable to the human.
 
Top