<% function FormItem(strIn, strFieldName, intFieldType) 'Gus Mueller, April 17 2000 'dishes out a different form item depending on the nature of the data dim strOut, str1checked, str0checked if instr(lcase(strFieldName), "notes") or instr(lcase(strFieldName), "text") then intFieldType=201 end if select case intFieldType case -1 strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine case 3 strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine case 17 strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine case 200 if strIn<>"" then if instr(strIn, chr(10))<1 and instr(strIn, chr(13))<1 then strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine else strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine end if else strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine end if case 201 strOut= strOut & vbTab & vbTab & vbTab & "" & vbNewLine case 135 strOut= strOut & vbTab & vbTab & vbTab & datepulldowns(strFieldName, strIn, true) & vbNewLine case 11 str1checked="checked" if strIn<>"" then if not strIn then str1checked="" str0checked="checked" else str0checked="" end if end if strOut= strOut & vbTab & vbTab & vbTab & " true" & " false" & vbNewLine case else strOut =strOut & intFieldType end select FormItem=strOut end function function DoubleQuoteHandle(byval strIn) if strIn<>"" then strIn=replace(strIn, chr(34), """) end if DoubleQuoteHandle=strIn end function function ExpedientForm(rstIn, rstDefault, strTargetFormLocation, strHiddenFields, strAdditional) 'Gus Mueller, April 17 2000 'generates a form based on a complete recordset, using the database labels 'and values 'rstDefault is a sample recordset for times when you just want a blank form 'to enter data in 'strHiddenFields is a ^-delimited list of fields to hide in the form dim strOut, field, bwlNoData, intFieldType, intOut, strDoneFields bwlNoData=false if not isobject(rstIn) then set rstIn=rstDefault bwlNoData=true elseif rstIn.eof then set rstIn=rstDefault bwlNoData=true end if intOut=1 strOut= strOut & "" & vbNewLine strOut= strOut & "" & vbNewLine for each field in rstIn.fields intFieldType=field.type if not inList(strDoneFields, field.name) then if inList(strHiddenFields, field.name) then intFieldType=-1 else intOut =intOut+1 strOut= strOut & RowHTML(intOut) & vbNewLine strOut= strOut & vbTab & vbTab & "" & vbNewLine strOut= strOut & vbTab & vbTab & "" & vbNewLine strOut= strOut & vbTab & "" & vbNewLine end if strDoneFields=strDoneFields & "^" & field.name end if next StrOut=strOut & strAdditional StrOut=strOut & RowHTML(intOut+1) & vbNewLine StrOut=strOut & vbTab & vbTab & "" & vbNewLine StrOut=strOut & vbTab & "" & vbNewLine strOut= strOut & "
" & vbNewLine strOut=strOut & "

" & vbNewLine strOut= strOut & "
" & vbNewLine strOut= strOut & LabelProcess(field.name) & " " strOut= strOut & vbTab & vbTab & "" & vbNewLine end if if bwlNoData then strOut= strOut & FormItem("", field.name, intFieldType) else strOut= strOut & FormItem(field, field.name, intFieldType) end if if intFieldType>-1 then strOut= strOut & vbTab & vbTab & "
" & vbNewLine StrOut=strOut & vbTab & vbTab & vbTab & "" & vbNewLine StrOut=strOut & vbTab & vbTab & "
" & vbNewLine StrOut=strOut & "" & vbNewLine ExpedientForm=strOut end function function LabelProcess(byval strIn) 'Gus Mueller, April 17 2000 'inserts space between case changes in a field name to improve readability dim intLen, t, chrThis, chrThat, chrNext, intStart if strIn<>"" then intLen=len(strIn) intStart=2 do until intStart>=intLen for t=intStart to intLen chrThis=mid(strIn, t, 1) chrThat=mid(strIn, t-1, 1) if lcase(chrNext)=chrNext and lcase(chrThis)<>chrThis and chrThat<>" " then 'new word! strIn=left(strIn, t-1) & " " & mid(strIn, t) exit for end if next intStart=t+1 loop end if LabelProcess=strIn end function function RequestProcess(strExclude, strAdditional) 'Gus Mueller, April 17 2000 'comes back with the bulk of a SQL statement with the parameters from the request object 'strExclude contains a ^-delimited list of fields to avoid processing. 'you still need to come up with a stored procedure and any additional parameters 'to include dim strSQLOut, objRequest, intCount, strValue, intSkip, strFieldPrefix, dtmThis strExclude=strExclude & "^submit" if request.form.count >0 then set objRequest=request.form else set objRequest=request.querystring end if intCount=0 for each field in objRequest if intSkip=0 then if not inList(strExclude, field) then if instr(field, "_month")<1 then if intCount>0 then strSQLOut = strSQLOut & "," end if strSQLOut = strSQLOut & "@" & field & "=" strValue=objRequest(field) if isNumeric(strValue) then strQuote="" else strQuote="'" end if strSQLOut = strSQLOut & strQuote & quote(objRequest(field)) & strQuote else 'handle the special case of date drop downs (three different inputs! 'that need to be combined into a single date intSkip=2 strFieldPrefix=split(field, "_")(0) dtmThis=datehandle(objRequest(field) & "/" & objRequest(strFieldPrefix & "_day") & "/" & objRequest(strFieldPrefix & "_year"), "12/31/99") if intCount>0 then strSQLOut = strSQLOut & "," end if strSQLOut = strSQLOut & "@" & strFieldPrefix & "=" strSQLOut = strSQLOut & "'" & dtmThis & "'" end if intCount=intCount+1 end if else intSkip=intSkip-1 'skip the extra date fields, which are already read end if next set objRequest=nothing if strAdditional<>"" then strSQLOut = strSQLOut & "," & strAdditional end if RequestProcess=strSQLOut end function function quote(strIn) 'escape single quotes for database dim strOut strOut=strIn if not isnull(strOut) then if strOut<>"" then strOut=replace(cstr(strOut), "'", "''") else strOut=null end if else strOut=null end if quote=strOut end function function inList(strIn, strPossibleBad) 'determines if strPossibleBad is within the ^-delimited list of strIn dim bwlOut, intParseBan bwlOut=false intParseBan=0 if strIn<>"" then if instr(strIn, "^") then arrBan=split(strIn, "^") do until intParseBan > ubound(arrBan) or bwlOut=true strPossibleBan=trim(arrBan(intParseBan)) if strPossibleBan<>"" then if lcase(strPossibleBan) = lcase(strPossibleBad) then bwlOut=true end if end if intParseBan=intParseBan+1 loop else if strPossibleBad<>"" then if lcase(strPossibleBad)=lcase(strIn) then bwlOut=true end if end if end if inList = bwlOut end function function RecordList(rstIn, strIDField, strLabelField, strDescriptionField, strProcessForm, intPerPage, intStyle) 'Gus Mueller, April 19 2000 'comes back with an index list from an index recordset, displayed with checkboxes and hyperlinks 'for working with the individual records. 'intStyles: 0-simple (no table) 1-table with alternating colors 2-table single color '3-table with the other single color 'strIDField is the primary key, used to identify a specific record 'strLabelField is the human-readable primary record identifier 'strDescriptionField is the record description 'strProcessForm is the URL of the form processor dim strOut, strPreHTML, strPostHTML, strMidHTML, strHeaderHTML, strFooterHTML, strRowEnd, intRowCount strOut="" strHeaderHTML="" & vbNewLine strPreHTML=vbTab & "" & vbNewLine strMidHTML=vbTab & vbTab & "
" & vbNewLine strPostHTML=vbTab & vbTab & vbTab & "
" & vbNewLine strFooterHTML="
" & vbNewLine strRowEnd=vbTab & "" & vbNewLine if intStyle=0 then strHeaderHTML="" strPreHTML="" strPostHTML="
" & vbNewLine strMidHTML=" - " strFooterHTML="" strRowEnd="" end if strOut=strHeaderHTML intRowCount=1 if intStyle=2 or intStyle=3 then intRowCount=2 end if do until rstIn.eof or intRowCount>intPerPage if intStyle>0 and intStyle<3 then strOut=strOut & vbTab & RowHTML(intRowCount) & vbNewLine elseif instyle=3 then strOut=strOut & vbTab & RowHTML(1) & vbNewLine else strOut=strOut & vbTab & RowHTML(2) & vbNewLine end if strOut=strOut & strPreHTML strOut=strOut & vbTab & vbTab & vbTab & vbTab & "" & vbNewLine strOut=strOut & vbTab & vbTab & vbTab & vbTab & "" & rstIn(strLabelField) & "" & vbNewLine if strDescriptionField<>"" then strOut=strOut & vbTab & strMidHTML & Truncate(rstIn(strDescriptionField), 40) & vbNewLine end if strOut=strOut & strPostHTML & vbNewLine & strRowEnd intRowCount=intRowCount+1 rstIn.movenext loop strOut= strOut & vbTab & RowHTML(intRowCount) & vbNewLine strOut=strOut & strPreHTML strOut=strOut & vbTab & vbTab & vbTab & vbTab & "new" & vbNewLine strOut=strOut & strPostHTML & vbNewLine & strRowEnd strOut=strOut & strPostHTML & strRowEnd strOut=strOut & strPostHTML & strRowEnd strOut= strOut & strFooterHTML RecordList=strOut end function function RowHTML(intIn) strOut="" if intIn/2=int(intIn/2) then strOut=vbTab & "" else strOut=vbTab & "" end if RowHTML = strOut end function function Truncate(strIn, intLimit) dim strOut strOut=strIn if len(strIn)>intLimit then strOut=left(strIn, intLimit-2) & "..." end if Truncate=strIn end function function RecordIndex(intThis, intPerPage, intTotal, strURLBase) dim strOut, t, intPages intThis=intThis/intPerPage intPages=int(intTotal/intPerPage) strOut="" for t= 0 to intPages if t=intThis then strPre="" strPost="" else strPre="" strPost="" end if strOut = strOut & strPre strOut = strOut & t+1 strOut = strOut & strPost & vbNewLine if t