Neil Coleclough wrote:
I want to restrict these buttons to single
use, so that once the email has been sent and the return confirmed, it
cannot then be clicked again potentially triggering an email each time
it is clicked. Other buttons on the form also print appropriate reports
to appropriate printers, in the interest of the rain forests, I want to
restrict these buttons so that once clicked, they cannot be clicked
again. I'd appreciate some guidance, in other words, please help!!
What brian and the other respondent have explained are all good, but the
important underlying thing is this:
You MUST have, somewhere in your data tables, a field which indicates,
for each record, whether or not the email has been sent, which report
have been printed.
So in your data structure, to which you don't provide any insight, you
might have something likt this:
TBL_REPORTS
REP_PK Primary key, autonumber
REP_NAME text, short name of a report
REP_DESCRIPTION text, comments, etc, if any on a report
REP_EMAIL_SENT date/time, initial value is null, populate with current
date/time when a report is emailed
REP_PRINTED as per REP_EMAIL_SENT, above.
Another (preferred, in my opinion) option would be to have a separate
table which indicates all instances of emailling and report printing
with a foreign key pointing to the report table.
I would not have the toggle button disabled. You will severely tick off
users who don't care about Treebeard's friends if they can't run reports
when they want.
What I would do instead is simply have something like the following as
an afterupdate event fo each individual toggle button as appropriate.
This is air code and assumes the displayed form is bound to an
underlying SQL statement or query with access to the date/time fields
for when report was sent/last sent. It also assumes the toggle button
is selected and then another button elsewhere prints reports based on
the toggles selected:
sub tglSelReport_afterupdate()
'response required if the toggle is turned on (value = -1) and
'the date last printed is populated.
if me.tglSelReport = -1 and isnull(me.REP_PRINTED) = False then
'This report has been printed on the date indicated by the
'field. Inform user and ask if they want to continue.
if msgbox("This report has been printed before on " & _
format(me.REP_PRINTED, "d mmm yyyy") & _
"If you want to avoid a Saruman type fate, it's " & _
"recommended that you press cancel and look around " & _
"for the report." & vbcrlf & vbcrlf & _
"Continue?", vbQuestion + vbOkCancel, _
"Already Printed!") = vbCancel then
'If action cancelled, turn off toggle button
me.tglSelReport = 0
End If
End if
end sub
--
Tim
http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me