On 6 Jun 2005 07:51:05 -0700, "BerkshireGuy" <bd*****@yahoo.com>
wrote:
David,
Sound good. Any possible leads of an example of this method anywhere?
Thanks!
-Brian
Hi
Here is a sample cobbled together with some refs imbedded in the
comments.
1. The code at the end should be saved as a .htm or .hta file.
If it is an hta file it will run without asking you about things being
unsafe, but as the object of the exercise is to send it to someone
else by email and for them to run it, you will probably find that
their email will reject hta files as unsafe - they are. Also you can
send html as the body of the email rather than as an attachment.
2. Change the line containg "receiversname" to hold the email address
you want the results returned to - you, presumably
3. Doubleclick on the file. Fill in some of the slots and press
submit. It should email you the results. (I have assumed Windows 2000
or XP with IE I'm afraid).
The idea is that the whole of the code would be generated by Access in
a suitable version for each respondent, and emailed to them from
Access. The code consists of a fixed header, a repeating portion (for
each line of the form) and a fixed final portion. In the example the
only bits that depend on the respondent are the names "project 1",
"project 2" etc. which appear in the repeating portion.
HTH
David
.... code follows
<html>
<head>
<script language='Javascript'>
function tellit(){
//turns results into a string
var i, projectcollection, dateapprovedcollection, reasoncollection,
stringout="";
var formElement = document.forms["myForm"];
projectcollection = formElement.elements["project"];
dateapprovedcollection = formElement.elements["dateapproved"];
reasoncollection = formElement.elements["reason"];
if(typeof projectcollection.length != "number"){
projectcollection = [projectcollection];
dateapprovedcollection = [dateapprovedcollection];
reasoncollection = [reasoncollection];
//to see what this is about see
//http://jibbering.com/faq/faq_notes/form_access.html
}
for (i=0;i<dateapprovedcollection.length; i++){
stringout=stringout + projectcollection[i].value + ";"
+ dateapprovedcollection[i].value + ";"
+ reasoncollection[i].value + ";\n";
}
return stringout;
}
</script>
<script type="text/vbscript">
function sendit()
'send email from vbscript, see more at
'http://www.paulsadowski.com/WSH/cdo.htm
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "approval data"
objMessage.Sender = "se*********@blueyonder.co.uk"
'above should be the email address of the sender,
'but it can be a dummy name like this one
objMessage.To = "re***********@blueyonder.co.uk"
'above is who the mail will be sent to
objMessage.TextBody = tellit()
objMessage.Send
msgbox "Thank you, message sent"
window.close
end function
</script>
</head>
<body>
<form name="myForm">
Project number, date approved, or reason not approved
<br>
<input type="text" name="project" value="project 1"; readonly>
<input type="text" name="dateapproved">
<select name="reason">
<option value="">Choose a reason...
<option value="0">Approved
<option value="1">Too expensive
<option value="2">Too cheap
<option value="3">Too quick
<option value="4">Too slow
</select>
<br>
<input type="text" name="project" value="project 2"; readonly>
<input type="text" name="dateapproved">
<select name="reason">
<option value="">Choose a reason...
<option value="0">Approved
<option value="1">Too expensive
<option value="2">Too cheap
<option value="3">Too quick
<option value="4">Too slow
</select>
<br>
<input type="text" name="project" value="project 3"; readonly>
<input type="text" name="dateapproved">
<select name="reason">
<option value="">Choose a reason...
<option value="0">Approved
<option value="1">Too expensive
<option value="2">Too cheap
<option value="3">Too quick
<option value="4">Too slow
</select>
<br>
<br>
<input type="button" value="Submit" onclick="sendit()">
</form
</body>
</html>