<% Dim RecSet 'Recordset object Dim rsTemp 'Recordset object Dim strSQL 'SQL Statement Dim intTotalPages Dim intCurrentPage Dim intCurrentRecord Dim intTotalRecords Dim strMoveNext Dim strMovePrevious Dim I Dim Zip, Miles, Types, Virtual 'Holds the search criteria Dim dLongitude, dLatitude 'The Longitude and Lattitude of the users zip code intCurrentPage = Request.QueryString("page") If intCurrentPage = "" Then intCurrentPage = 1 End if 'Connect to the database If ConnectToDatabase <> "" Then DisplayError("Could not connect to the database. It may be temporarily under maintanence. Please try again in a few minutes.") End If 'Get the users settings If Session("UserID") <> "" Then '>>>On Error Resume Next Set RecSet = Server.CreateObject("ADODB.Recordset") If Session("Type") = 1 Then RecSet.Open "Select Zip From [NonProfits] Where UserID='" & Session("UserID") & "'", dbConnection, 2, 2 Else RecSet.Open "Select ltrim(rtrim(Zip)) Zip From [Volunteers] Where UserID='" & Session("UserID") & "'", dbConnection, 2, 2 End If If Err <> 0 Then DisplayError("Could not connect to table. It may be temporarily under maintanence. Please try again in a few minutes.") End If If Not RecSet.EOF Then Zip = RecSet("Zip") End If 'Miles = rsUser("PrefMiles") 'Virtual = rsUser("PrefVirtual") RecSet.Close Set RecSet = Nothing End If 'if request.Form("txtZip")="" and Request.Form("chkVirtual") <> "" then 'zip = "" 'end if 'Get the submitted form data If Request.Form("txtZip") <> "" Then Zip = Request.Form("txtZip") End If If Request.Form("cboMiles") <> "" Then Miles = Request.Form("cboMiles") End If if request.form("lstServiceTypes")="" or request.form("lstServiceTypes")="29" Then Types ="29" End If If Request.Form("lstServiceTypes")<> "29" Then Types = Request.Form("lstServiceTypes") End If If Request.Form("chkVirtual") <> "" Then 'response.write(Request.Form("chkVirtual")) Virtual = Request.Form("chkVirtual") End If %> HelpNet USA - Volunteer Opportunity Search
HelpNet USA

Menu:

Volunteer Opportunity Search

Search

* Search our database for local or virtual volunteer opportunities that match your service preference.

  * Enter your zip code and distance you're willing to travel, or search for virtual opportunities only.

  * Thank you for volunteering!

Volunteer Opportunity Search
Zip Code   Max Distance miles
  OR
Work from home only "" Then Response.Write "checked"%>>

Type of Work Preference

Hold [CTRL] down to
select multiple items

<% sub createsql() If (dLatitude <> 0 or dLongitude <> 0) and Request.Form("chkVirtual")= "on" then strsql =strSQL & " AND (Opportunities.Zip IN ( SELECT Zip FROM CityStateZip " _ & "WHERE " & Miles & " > 3959 * ACOS(SIN(" & dLatitude & "/ 57.3) * SIN(Latitude/ 57.3) + " _ & "COS(" & dLatitude & "/ 57.3) * COS(Latitude/ 57.3) * " _ & "COS((Longitude/ 57.3) - (" & dLongitude & "/ 57.3)))) or Opportunities.VirtualOpp=1 )" exit sub end if If dLatitude <> 0 or dLongitude <> 0 then ' Request.Form("chkVirtual") <> "on" Then strSQL = strSQL & " AND (Opportunities.Zip IN ( SELECT Zip FROM CityStateZip " _ & "WHERE " & Miles & " > 3959 * ACOS(SIN(" & dLatitude & "/ 57.3) * SIN(Latitude/ 57.3) + " _ & "COS(" & dLatitude & "/ 57.3) * COS(Latitude/ 57.3) * " _ & "COS((Longitude/ 57.3) - (" & dLongitude & "/ 57.3))))) " Else If Request.Form("chkVirtual") = "on" Then strSQL = strSQL & " AND Opportunities.VirtualOpp=1 " end if end If end sub dim strsql1 If Ucase(Request.QueryString("Search")) = "TRUE" and (Zip <> "" or Virtual <> "") Then 'Get the longitude and latitude of their zip code Set RecSet = Server.CreateObject("ADODB.Recordset") if Zip<>"" then RecSet.Open "SELECT Latitude, Longitude FROM CityStateZip WHERE Zip='" & Zip & "'", dbConnection If Not RecSet.EOF Then dLatitude = RecSet("Latitude") dLongitude = RecSet("Longitude") RecSet.Close Set RecSet = Nothing end if end if 'Make sure we have coordinates for the Zip Code If (dLatitude = 0 or dLongitude = 0) and Request.Form("chkVirtual") <> "on" Then Response.Write "
Zip Code Does Not Exist
" Else 'Generate the SQL statement Set RecSet = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT DISTINCT NonProfits.Zip, NonProfits.OrgName, Opportunities.OpportunityID, Opportunities.VirtualOpp, Opportunities.OpportunityName, Opportunities.StartDate, Opportunities.EndDate, Opportunities.UserID " _ & "FROM (NonProfits INNER JOIN Opportunities ON NonProfits.UserID = Opportunities.UserID) LEFT JOIN UserServiceTypeJoin ON NonProfits.UserID = UserServiceTypeJoin.UserID " _ & "WHERE (EndDate >= getdate() OR Opportunities.OngoingOpp = 1) " call createsql() If types = "29" then strSQL = strSQL & "AND UserServiceTypeJoin.ServiceTypeID IN (select servicetypeid from servicetypes)" else if types<>"" then strSQL = strSQL & "AND UserServiceTypeJoin.ServiceTypeID IN (" & Types & ")" end if End If strSQL = strSQL & ";" 'response.write strSQL RecSet.CursorLocation=3 RecSet.Open strSQL, dbConnection, 3 '3=adOpenStatic RecSet.PageSize = 25 'Display the search results If RecSet.EOF Then Response.Write "
No Matching Opportunities Found
" Else RecSet.AbsolutePage = intCurrentPage intTotalPages = RecSet.PageCount intCurrentRecord = RecSet.AbsolutePosition intTotalRecords = RecSet.RecordCount Response.Write "
" & intTotalRecords & " matching opportunities found

" For i = intCurrentRecord To intCurrentRecord + RecSet.PageSize - 1 'display from the current record to the pagesize If Not RecSet.EOF Then %>
','OpportunityDetails',500,500)"><%=RecSet("OpportunityName")%>
Organization: <%=RecSet("OrgName")%>
<%If Not IsNull(RecSet("StartDate")) Then Response.Write "When: " & RecSet("StartDate") & " to " & RecSet("EndDate") Else Response.Write "Ends: " & RecSet("EndDate") End If%>

<% RecSet.MoveNext End if Next 'Display Page Navigation Select Case Cint(intCurrentPage) Case Cint(intTotalPages) 'If its the last page give only links to Move First and Move Previous If Cint(intTotalPages) = 1 Then strMoveNext = "Next >" strMovePrevious = "< Prev" Else strMoveNext = "Next >" strMovePrevious = "< Prev" End If Case 1 'if its the first page only give links To move Next and move last strMoveNext = "Next >" strMovePrevious = "< Prev" Case Else strMoveNext = "Next >" strMovePrevious = "< Prev" End Select %>
<%=strMovePrevious%> Page <%=intCurrentPage & " of " & intTotalPages%> <%=strMoveNext%>
<% End If RecSet.Close Set RecSet = Nothing end if End If %> <% dbConnection.Close Set dbConnection = Nothing %>