Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I grab the last value in a series?

Status
Not open for further replies.

tsefly

Programmer
Nov 5, 2001
5
US
Hello all,

first time posting a question.

I have a list of report names in two different directories, one being an archive, the other reports that are overwritten monthly. The archived reports start with a year_month_. The web has drop down option boxes for year and month.

So far, everyting works great. I am creating the archive based on user login (determines which reports can be "released" or "signed off". So, the reports also include a division name in the title. However, once the reports are signed off, anyone may look at them.

So, how do I pick one particular report out of many? My idea was to list the reports, using instr to search for both the report name and the requested month and year. It works, but then just moves onto the next file, so that the variable for report name is continually replaced and made useless. How do I say until this, do that, save last? Here is my code. The response.write stuff is just trouble-shooting junk.


Function PagePath()
Dim Mth, Yr
vServer = Request.ServerVariables("SERVER_NAME")
s=" & vServer & "/SafetyFirst/Reports/"
a=" & vServer & "/SafetyFirst/Archive/"

Mth=trim(request("Mth"))
Yr=trim(request("Yr"))
Connector = "_"

if Yr = "CurrentY" then
PagePath=s
ReportPrefix = ""
Else
If Mth = "CurrentM" then
PagePath=s
ReportPrefix = ""
Else
ReportPrefix= Yr & Connector & Mth & Connector
PagePath=a
End If
end if

dim filename, filecollection, strArchivePath, strCurrentPath, strFileExt

strArchivePath= "\\" & vServer & "\
'establish path to input and output files

Set objfso = CreateObject("Scripting.FileSystemObject")
Set objArchive = objfso.GetFolder(strArchivePath)

If ReportPrefix <> &quot;&quot; then

Set filecollection = objArchive.Files
For Each filename in filecollection
vResult = (Instr(filename, reportprefix))
xResult = (Instr(filename, strReport))
Response.Write &quot;strReport = &quot; & strReport
Response.Write filename
Response.Write xResult & &quot; = xResult&quot;
Response.Write vResult & &quot; = vResult&quot;

if vResult <> 0 and vResult <> &quot;&quot; and xResult <> 0 and xResult <> &quot;&quot; then
strReport = filename
end if
Next
End if
End Function
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top