Problem with filtering query recordset from Data Access Page

G

Guest

I have a query that is only supposed to return one record. I am able to
choose the record I want by setting the criteria for my ID field. Everything
works up to there. What I'm trying to do is run a Data Access Page off of
this query with the ability to filter the query based on a value (from a
dropdown but I don't need help with that). Getting the value is not a
problem, the problem is when I try using...

MSODSC.RecordsetDefs("HistoryQuery").serverfilter = "EmpID = '" & EmployeeID
& "'"

....my page can run but it loads nothing; every control is left blank. When
I comment out that line, make my query a parameter query and then type in the
correct parameter when running the page, everything works fine. Why does my
page not load when using that line of code (though I get no errors)? How
else can I do this?

Here is the script I threw in right before the closing </HEAD> tag:

<SCRIPT language=vbscript event=BeforeInitialBind(info) for=MSODSC>
<!--
dim EmployeeID

EmployeeID = window.dialogarguments
MsgBox EmployeeID
MSODSC.RecordsetDefs("HistoryQuery").serverfilter = "EmpID = '" & EmployeeID
& "'"
-->
</SCRIPT>

Please Help!!

Thanks,
Matt
 
K

Ken Snell \(MVP\)

Is the script that sets the server filter of the query located in the DAP
that is bound to that query? Assuming that it is.....

When I do this type of script, I usually create a string of the filter
criterion expression, and specifically cast the "inserted parameter value"
so that VBScript doesn't reinterpret for me:


<SCRIPT language=vbscript event=BeforeInitialBind(info) for=MSODSC>
<!--
dim EmployeeID
Dim strFilter

EmployeeID = window.dialogarguments
MsgBox EmployeeID
strFilter = "EmpID='" & CStr(EmployeeID) & "'"
MSODSC.RecordsetDefs("HistoryQuery").serverfilter = strFilter
& "'"
-->
</SCRIPT>


Try the above and see if it works.

I've never used Window.DialogArguments for passing the parameter; I usually
have used a cookie that is read by the DAP being filtered. But, you say
you're getting the right value from that script step, so it probably is not
an issue here.

VBScript is a poor system for telling you when an error occurs. Usually, you
get no errors and nothing happens... the only way to find out if a code step
is failing is to put MsgBox lines in between every line of script so that
you can trace the script and identify which code step failed and thus the
script stopped.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top