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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with Search Form

Status
Not open for further replies.

simpsondm

IS-IT--Management
Jan 14, 2003
21
US
Well I'm back with another question. Im having problems making a search form. Heres my case. I have a Table called tbl_ProjectMain in this table I have many fields but I'm trying to create a search form that has a textbox that will accept text or numbers and when entered you click a button and it will search against any or all of these 4 fields (Recid, PID, PIDO, Pewd) and will return the resulting record or records in like a dataview/tubular view in the bottom of the form allowing the user to select and open that record up.Or that will just open my main form to that record.

Can anyone please help
 
Depends a little on the field types of Recid, PID, PIDO, Pewd. Also depends on what fields you want to display. For instance, let’s assume these are all text fields, and you want to find the first and last names for records that match the search. You could try this, where “btnSearch” is a command button that initiates the search and “ResultList” is a listbox that displays the matches.

Private Sub btnSearch_Click()
Dim strWhere As String

strWhere = "SELECT distinct [First Name], [Last Name] from tbl_ProjectMain where “
strwhere = strWhere & “[Recid] Like ‘” & [texttosearchfor] & “*’”
strWhere = strWhere & “ Or [PID] Like ‘” & [texttosearchfor] & “*’”

' etc... for the other fields

ResultList.RowSourceType = "Table/Query"
ResultList.RowSource = strWhere

End sub


Hope that helps,
Len
 
D24S,

Check out my Tips thread at thread181-262790

Hopefully that will help. _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top