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

Adding Command Button to Search Access Page 1

Status
Not open for further replies.

Weim

Programmer
Aug 20, 2005
6
US
I really need some help trying to fiugure this out. I'm just starting to dive into the world of Access and this is the first VBA experience I have had. So here's the sccop.

I have an Access database. In column 1 are numbers, in column 2 are descriptions that contain multiple words.

I created an Access page and saved the HTML file. Users can now view the database via a web browser.

I then wanted to add a search button to that HTML page. I added the Command Button and then.....

From the Microsoft web site I built this into the code:

<SCRIPT language=vbscript event=onclick for=command0>
<!--
' Clone the recordset.
Dim rs
Set rs = MSODSC.DataPages(0).Recordset.Clone
On error resume next
-->
rs.find "Description = '" & cStr(inputbox("Enter a Key Word","Find")) &"'"
' Custom error handling.
If (err.number <> 0) Then
Msgbox "Error: " & err.number & " " & err.description,,"Invalid Search"
Exit Sub
End If
' Check search results for success.
If (rs.bof) or (rs.eof) Then
Msgbox "No Product found",,"Search Done"
Exit Sub
End If
MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark
-->
</SCRIPT>

Now that all works fine, BUT, the description the user enters in has to match EXACTLY what's in the database for it to return any results. I want the user only to enter in a key word.

For example: In the database in the "Description" column there maybe be an entry "Great Oak Tree"

I would like the user to use the command button, enter in just "Oak" and get a result.

Seems easy enough, just need to put a * somewhere in the script......right?

Thanks
Jeff
 
You may try this:
rs.Find "Description Like '%" & CStr(InputBox("Enter a Key Word","Find")) & "%'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
It Works!

A huge thank you, much appreciated!!

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top