I guess I'm getting confused here. There aren't any fields in my table
that
are tied to these checkboxes but I would want to record the state for
each
record. Sorry about the confusion. Right now they're not bound to
anything
but I would like them to be to store their state.
I do want to see the email addresses but if I can access them from a
different form for modifications, etc. then I'd prefer that. I wasn't
aware
of the DLookup function and that's why I chose to put the textboxes.
I have no current fields that are linked to this email function. I
would
like to create the fields for these checkboxes to store the state. I
guess
I
wasn't understanding everything you said. Sorry again!
:
I thought we'd established that they were unbound and that there were
not
any fields in your record to store their state :-S
And no, you don't need the textboxes, but I thought you wanted them so
the
user could see the email addresses.
So, what fields DO you have in your recordset that are related to this
emailing operation?
--
Graham Mandeno [Access MVP]
Auckland, New Zealand
message Well wouldn't these checkboxes and textboxes have to be bound to
save
the
state they are in for that particular record? Also, if I'm going to
use
the
DLookup then I guess I don't even need the textboxes. I could just
have
the
checkboxes point to the table where the email addresses are stored.
:
OK, so the five checkboxes and the five textboxes are all unbound?
In this case, let's say the checkboxes are named chkEmail1, 2, 3
etc
and
the
textboxes are named txtEmail1, 2, 3 etc, and the EmailID for
CEOCheck
is
1,
SalesCheck is 2, etc.
You can bind each textbox to an expression that looks up the
corresponding
email address.
For txtEmail1:
=IIf(chkEmail1=0, Null, DLookup("EmailAddress",
"tblEmailAddresses",
"EmailID=1"))
....and so on for the others.
You might have to requery the corresponding textbox in the
AfterUpdate
procedure of each checkbox if it doesn't happen automatically:
Private Sub chkEmail1_AfterUpdate()
txtEmail1.Requery
End Sub
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
in
message Hi Graham,
I will do my best to answer your questions...
The form has about 20 more controls on it and is used to enter
corrective
actions. The check boxes are used to send a notification email to
the
managers to let them know the corrective action is complete and
ready
for
them to sign off on it. The form is bound to a table called
"tblCorrectiveActions". There is nothing else on the form that
preordains
the
state of the checkboxes. It's just used as a trigger to let the
email
function know which managers to email. What I want to do now is
set
up
another table with just 3 fields in it. "EmailID", "Title", and
"EmailAddress". Then I want to use the DLookup function to lookup
each
email
address and send it to the ones that are checked using the
checkboxes.
Each
check box has been defined as "CEOCheck", "SalesCheck",
"EngineeringCheck",
"ProductionCheck", and "QualityCheck". So I was thinking the
DLookup
could
look for the title that matches the check box and then use the
email
address
in that record. I hope what i wrote makes sense. Let me know if
you
need
more
information.
:
Hi SS,
I'm sorry, I really can't tell you the best way to do this
unless
you
give
some more details about your structure and business rules and
answer
my
previous questions. In particular:
What else is on your form? I assume the form is bound - what is
its
recordsource?
Is there anything in the content of the current record that
preordains
the
state of the checkboxes (or the corresponding email addresses)
for
each
record?
--
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Secret Squirrel" <
[email protected]>
wrote
in
message
Hi Graham,
After several test attempts I finally have it working. I had
to
tinker
with
it a bit but it doing exactly what you said it would. Thank
you
very
much!
I
do have one follow up question...First I do agree that maybe
putting
these
into a table instead of hard coding it is a better approach.
How
would
I
set
up the DLookUp for this scenerio?
:
Do the checkboxes have anything in their ControlSource
properties?
This
is
what defines bound/unbound.
ControlSource can either be:
a) blank: the control in unbound and any value is put
there
either
by
the user (if it's editable) or by code.
b) an expression starting with "=": the value is
calculated
and
cannot
be modified by the user or by code
c) the name of a field in your recordsource: the control
is
bound
to
that field - if the field changes the value in the control
changes,
and
vice-versa.
If the checkboxes all correspond to fields in your source
table
then
they
are bound, and will change as you move from one record to the
next.
This
is
what you implied in your penultimate post, but not in your
last
post,
so
I'm
still unsure of the situation.
Where do the email addresses come from? Are they in a table
somewhere?
What else is on your form? Is there anything in the content
of
the
current
record that preordains the state of the checkboxes (or the
corresponding
email addresses) for each record?
--
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Secret Squirrel" <
[email protected]>
wrote
in
message
Well here's exactly what I'm trying to do. I want to put 5
checkboxes
on
my
form that will trigger an email address in 5 different
textboxes.
So
when
a
user clicks on one of the check boxes then the email
address
that
is
tied
to
that check box appears in the corresponding textbox. Once
the
user
checks
all
the boxes he/she needs then they can click a command button
to
generate
the
email to those email addresses that are shown in the text
boxes.
I
haven't
added any of these fields yet until I know exactly how to
set
it
up.
The
form
I use is a single view so I would need the users to be able
to
choose
different checkboxes depending on the record they are
updating. I
think
I
understand the code you wrote but the bounb/unbound part is
confusing
me.
i.e.
CheckBox1 = True
CheckBox2 = True
CheckBox3 = True
CheckBox4 = False
CheckBox5 = False
TextBox1 = "(e-mail address removed)"
TextBox2 = "(e-mail address removed)"
TextBox3 = "(e-mail address removed)"
TextBox4 = Null
TextBox5 = Null
:
Hmmmm... I didn't realise these checkboxes were bound. I
somehow
assumed
they were unbound.