This topic is locked

Filter child records by master table fields

5/7/2009 1:23:48 PM
ASPRunnerPro General questions
author

I know this should be easier than I am making it!
In the example below, can anyone tell me a how I can automatically load the resulting child list page filtered by fields in the master page. The first and last record in the child table should be filtered out. The tables are linked on VehicleID and Date.
Master Table

ID VehicleID Date RunStart RunEnd

1 Police1 5/7/09 0800 0900
Child Table

VehicleID Date AVLPing

Police1 5/7/09 0755

Police1 5/7/09 0815

Police1 5/7/09 0845

Police1 5/7/09 0913

I know I have to create a "Before SQL Query" event on the child list page and that the strWhere clause will be something to the effect of "Where AVLPing between RunStart and RunEnd" but I am a little lost.

4414 5/7/2009

Ok, it WAS easy and I figured it out. Just needed another cup of coffee and a little Jelly Roll Morton to clear my brain.
[codebox]str = "SELECT Time_Assigned, Time_At_Scene FROM dbo.vwAMRRawVehicles WHERE (AVLUnit = '"& request.querystring("masterkey4") & "') AND (IncYear = "& request.querystring("masterkey1") & ") AND (IncMonth = "& request.querystring("masterkey2") & ") AND (IncDay = "& request.querystring("masterkey3") & ")"

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection
Session("TStart") = rstmp("Time_Assigned")

Session("TEnd") = rstmp("Time_At_Scene")

rstmp.close

set rstmp=nothing
strWhereClause = whereAdd(strWhereClause,"AVLDateTime between '" & session("Tstart") & "' and '" & session("Tend") & "'")[/codebox]