Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search db from one or two of many fields

Status
Not open for further replies.

maloaupito

Technical User
Jun 28, 2001
21
0
0
US
I want to display database results from a few of many search fields. I basically have a database of names and addresses of many graduating classes. Say I want to search for the address of an old friend who I only remember as Mary and graduated in 1975. From available search fields of FirstName, LastName, MaidenName, and YearGraduated (drop-down list), the user would type in Mary and choose 1975 - using only TWO of the available 4 search fields and the resulting info is displayed.

I figured out how to use FP 2003 DRW to display records from just one available search field but not the above.
 
I think you would need to pull the values from your form and have it create a custom SQL query.

I think you will first need to determine the search criteria based ont he fileds the user has filled in.
Something like: (enough to get you started)

Criteria = ""
If len(UserSpecifiedFirstName) > 0 Then
Criteria = "FirstName = UserSpecifiedFirstName"
End If

If len(UserSpecifiedLastName) > 0 Then
If len(Criteria) > 0 Then
Criteria = Criteria & " AND LastName = UserSpecifiedLastName"
Else
Criteria = "LastName = UserSpecifiedLastName"
End If
End If


Then you can use that criteria in your SQL Query
Something like:

"Select FirstName, LastName, Maidenname, YearGraduated FROM Results WHERE FirstName = UserSpecifiedFirstName AND " & criteria





I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top