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!

Values from Functions 1

Status
Not open for further replies.

TonyRosen

Programmer
Jul 28, 2003
108
US
The Code:

Code:
function getprojectinfo(pn,pd,yr,var)
call opendb()
	strsql = "select pid," & var & " from pbr where projectnumber = '" & pn & "' and period = '" & pd & "' and year = '" & yr & "';"
	'response.write strsql
	set objrs = objconn.execute(strsql)
	if objrs.eof or objrs.bof then
		strsql = "select top 1 pid," & var & " from pbr where projectnumber = '" & pn & "' order by pid desc;"
		set objrs = objconn.execute(strsql)
		if objrs.eof or objrs.bof then
			myvar = ""
		else
			id = objrs(0)
			myvar = objrs(1)
		end if
	else
		id = objrs(0)
		myvar = objrs(1)
	end if
call closedb()
end function

Then, I call the function using:

if getprojectinfo(request("projectnumber"),request("period"),request("year"),"pbrtype") = "Baseline" then
' Do this
end if

However, it doesn't recognize anything within the function.

If I add a response.write in the function, it will print out "Baseline".

How do I use what it finds?

 
You set the name of the function to whatever value you want returned.

So...

Code:
...
...
call closedb()
[!]getprojectinfo = myvar[/!]
end function

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top