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!

Data Access Page - Search Button (Access 2003)

Status
Not open for further replies.

FunkFly555

Technical User
May 20, 2009
2
0
0
GB
Hi,
I would be very appreciative if you can help me with the following.

Using: Access 2003
Object: Pages (data access page)
Problem:
I've build a data access page and would like to add a search button on the page that would allow a user to enter a Company name that would then bring up the corresponding companies details after clicking find.

How I went about it:
I've deactivated the 'Control Wizard', clicked on the 'Command Button' tool and then clicked in the Header section of my Page under design to place the button. I then went into the 'Microsoft Scrip Editor', selected my object in the dropdown 'command0' then select 'onclick' in the event dropdown where I add the following 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 "Company Name = '" & 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>

I then saved my work and tested the button in the web page preview only to get the following error after clicking on the Find button after entering the company name I would like to search.

Error: 3001 Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another

Please can you advice me / give me an alternative in achieving a way of searching/ selecting records from a Data access page.
 
I would add a textbox (txtSeachFor) for the search criteria
2 buttons - "apply filter" and "remove filter"

Private Sub apply_filter_click()
Me.Filter = "SearchFieldNameInTable like '*" & me.txtSearchFor & "*'"
Me.FilterOn = True
End sub

Private Sub remove_filter_click()
Me.FilterOn = false
End sub

Note I included the “like *” so all records that contain the words would appear.

Hope this helps!
 
Hi T111,
Thank you for your reply. Appreciated!

The code works like a bomb when doing forms but it gives me errors using it in my Data Access page (Microsoft Scrip Editor). I'm kinda new to programming, but have a general idea of what’s going on.

Still not resolved, seems like it should be easy and starting to wonder if I'm missing something fundamental here.

Please advice if you have any ideas.
 
Maybe you need to change the search from

"like '*Bla*'

to

"like N'%Bla%'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top