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
-->
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
-->