![]() |
|
|||||||
| ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum? |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I entered code into the Script Editor for a Command Button on a Data Access Page that will prompt the user to find a text string. I followed the code from this link:
Adding Custom Filtering and Search Functionality to a Page Section named: Add a Find Button to a Page I typed in the code in the "On Click" event for the Cmmd Button in the Script Editor. I am getting a 3265 error "Item cannot be found in the collection corresponding to the requested name or ordinal. I have a NAME field and an ABBREVIATION field. I would like the user to be able to type in the Name and find it's abbreviation. Another problem is that I don't understand where to put the oEventInfo code that they claim unblocks MS Data Source Control events. When I put it in, my page gets errors. <SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)> I took college classes on VB and VBA around 6 years ago and haven't done this on the job since then, so I am very rusty with all this. This is my code. <SCRIPT language=vbscript event=onclick for=cmmdFindName> <!-- 'Clone the recordset. Dim rs Set rs=MSODSC.DataPages(0).Recordset.Clone On error resume next rs.find "NAME= '" & CStr(InputBox("Please enter word to find", "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 succes. If(rs.bof) or (rs.eof)Then Msgbox "No Name found",,"Search Done" Exit Sub End If MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark --> </SCRIPT> |
|
This ad is part of our Revenue Sharing program |
|
|||
|
Yes. This is a Data Access Page so it is linking to data in an Access Database. There is no "Find" feature on the Data Page navigation. I want to only display 5 records at a time on the page because it looks nicer. Therefore, the IE Find will only search the 5 records showing and not the entire list of records. I am trying to make a command button that will search all the data so the users do not have to look page by page. The link on Microsoft shows how to do it, but I am getting the error after the Find window pops up and I type in the value I am looking for.
|
|
||||
|
well my suggestion is to not do it the way they are saying to do it. I would do it more like this:
HTML Code:
|
|
|||
|
I tried the code and it stopped at the same place it did before. I didn't have the error checking code in place, but I'm sure it probably will give me the same error. It gets to the test that it called the sub.
The script editor also took out quotation marks when I saved it. Here is the code: <HEAD> ‘The script editor takes the quotes out when I save. <SCRIPT type=text/vbscript> Sub mySub() Dim rs Set rs=MSODSC.DataPages(0).Recordset.Clone On error resume next rs.find "WORD= '" & CStr(InputBox("Please enter word to find", "FIND"))& "'" 'test alert("mySub() was called when you clicked") MSODSC.DataPages(0).Recordset.Bookmark = rs.Bookmark End Sub </SCRIPT> (/HEAD> ‘The script editor does not accept the quotes around button, find and my sub. <BODY> onclick=mySub() tabIndex=16 type=button value=Find></DIV></BODY></HTML> |
|
|||
|
I started totally from scratch and used the Microsoft code. It works now. I think I was trying too many things and something was wrong somewhere that I couldn't find. I think it was also because I had the page grouped. I created a new page ungrouped. I started out that way and since it wasn't working, I thought the page had to be grouped.
Thanks for you help anyway. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VbScript to update/delete/ insert in Access | peachtea | ASP & VBScript Forum | 4 | 06-14-2008 12:02 PM |
| Example of Inserting and Retrieving data from xml file | hanusoft | Web Developers & Development Software | 0 | 10-01-2007 06:26 AM |
| VBScript Permission Access Denied | general_iroh | ASP & VBScript Forum | 1 | 06-28-2007 04:16 AM |