//flex table opened by JP

Click to See Complete Forum and Search --> : access 2k3 - data access page search function


csamuels
01-10-2005, 10:22 AM
I’m having problems trying to construct a database for my company. They need the database to enter information about certain insurance policies that our company has. We have a table setup and ready to go. I need to allow multiple users to add records to the database so I want to setup a Data Access Page to accomplish this. However, there’s a problem I’m still stuck on.

In the Data Access Page, I need the ability to search and display a record designated by the primary key field (policy number). I found code to do this, however when I goto inject the code into my page, it screws up by either displaying a blank page or only displaying my header. I try to inject the code by adding a command button, right click the button, click Visual Script Editor, select the object in the drop down, select the onclick event, add my code. Here’s the code from http://office.microsoft.com/en-us/assistance/HA010345491033.aspx

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

<SCRIPT language=vbscript event=onclick for=Command0>
<!--
' Clone the recordset.

Dim rs
Set rs = MSODSC.DataPages(0).Recordset.Clone
On error resume next

' This line assumes that the value you are filtering on is an integer.
' If the search value is a string, use slightly different syntax.
' For example, "CustomerID = '" & CStr(InputBox("Please enter customer to find", "Find")) & "'"
' rs.find "ProductID=" & cLng(inputbox("Enter a ProductID","Find"))
rs.find "CustomerID = '" & CStr(InputBox("Please enter customer 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 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
-->

CompGeek01
01-10-2005, 11:16 AM
I'll try to be as helpful as possible, but my knowledge of Access is limited.

Where is the Access Page viewed from? Access? Is that the complete script? Do you need ending <SCRIPT> tags?

ScaryBinary
01-10-2005, 11:29 AM
You could comment out the "On Error Resume Next" statement and see if Access or the script engine is reporting a particular error. Might give us some additional clues.

csamuels
01-11-2005, 09:41 AM
I've removed the script tag for MSODSC. I was using Access 2k3 to create and view the page, tested in IE 6 as well. I crossed over to Access 2000 and now the script works almost as it should. I click the button the prompt comes up, I input a known policy number but i get an error stating Error: 3265 the item cannot be found in the collection corresponding to the requested name or ordinal.

csamuels
01-11-2005, 02:01 PM
turned out to be that i had to change CustomerID to the feild i wanted the page to search from. This issue is resolved.