Access Data Access Page - filter for date range

Joined
Jul 31, 2008
Messages
1
Reaction score
0
Hi everybody,

I've created a data access page that prompts the user for a set of dates that are to be used as search parameters for another data access page. The 'Search' page is set up and works beautifully. It accepts the dates as cookies and, from all indications passes them without issue.

My other dap, the 'Results' page isn't playing well with others, though. It's based on a query (qryCalls) and needs to filter out the dates based on the parameters.

I'm not an expert with data access pages, but I'm pretty proficient...at least I thought I was until I tried to pass data back and forth between two daps. Please help, if you can!

Here's the code that I've put together for both pages so far. The last line of the Results page was my last attempt. I also tried an 'rs.Find' method with little success, but that could just be my inexperience.

Search page --
Code:
dim pStartingDate 
dim pEndingDate 
dim rs 
dim strCookie 
dim intLoc 
dim StartingDate 
*
if len(StartDate.value) = 0 then 
msgbox "You must enter a value for the starting date", vbexclamation, "Date error" 
StartDate.focus() 
exit sub 
end if 
*
if len(EndDate.value) = 0 then 
msgbox "You must enter a value for the ending date", vbexclamation, "Date error" 
EndDate.focus() 
exit sub 
end if 
*
if datediff("d", Date(), StartDate.value) > 0 then 
msgbox "Start date cannot be a future date", vbexclamation, "Date error" 
StartDate.value = "" 
StartDate.focus() 
exit sub 
end if 
*
if datediff("d", Date(), EndDate.value) > 0 then 
msgbox "End date cannot be a future date", vbexclamation, "Date error" 
EndDate.value = "" 
EndDate.focus() 
exit sub 
end if 
*
if datediff("d", EndDate.value, StartDate.value) > 0 then 
msgbox "End date must have occurred after the Start date", vbexclamation, "Date error" 
StartDate.value = "" 
EndDate.value = "" 
StartDate.focus() 
exit sub 
end if 
*
pStartingDate = StartDate.value 
pEndingDate = EndDate.value 
*
document.cookie = "StartDate=" & pStartingDate 
document.cookie = "EndDate=" & pEndingDate 
*
'msgbox "The cookie holds the following value: " & document.cookie 
*
window.open "Results.htm","_self"
*
Results page --
Code:
dim strCookie 
dim intLoc 
dim StartingDate 
dim EndingDate 
*
strCookie = document.cookie 
intLoc = instr(strCookie,"StartDate=") 
*
if intLoc > 0 then 
StartingDate = mid(strCookie, intLoc + 10) 
intLoc = instr(StartingDate, ";") 
if intLoc > 0 then 
StartingDate = Left(StartingDate, intLoc-1) 
end if 
end if 
*
'msgbox "Starting date = " & StartingDate,,"Start Date" 
*
strCookie = document.cookie 
intLoc = instr(strCookie,"EndDate=") 
*
if intLoc > 0 then 
EndingDate = mid(strCookie, intLoc + 8) 
intLoc = instr(EndingDate, ";") 
if intLoc > 0 then 
EndingDate = Left(EndingDate, intLoc-1) 
end if 
end if 
*
'msgbox "Ending date = " & EndingDate,,"End Date" 
*
'MSODSC.RecordsetDefs("qryCRS_Data_Log")..ServerFilter = "DateField > " & StartingDate & "DateField < " & EndingDate
 

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