CheckBox

G

Guest

Ok I always seem to have problems with checkboxes and could use some help here.

I have a checkbox and a textbox on my form. I want the text box to be
populated with an email address when the checkbox is checked. And when it's
unchecked I want the textbox to be blank. First how do I create the "IF"
statement for that and do I put the same "IF" statement in the "AfterUpdate"
event of the checkbox and the "CurrentEvent" of the form? Second, are both
the checkbox and textbox bound to fields on my table or is just the checkbox
bound to a yes/no field?
 
A

Armen Stein

Ok I always seem to have problems with checkboxes and could use some help here.

I have a checkbox and a textbox on my form. I want the text box to be
populated with an email address when the checkbox is checked. And when it's
unchecked I want the textbox to be blank. First how do I create the "IF"
statement for that and do I put the same "IF" statement in the "AfterUpdate"
event of the checkbox and the "CurrentEvent" of the form? Second, are both
the checkbox and textbox bound to fields on my table or is just the checkbox
bound to a yes/no field?

Both the fields should be bound, if I understand what you're trying to
do.

Some air code:

in the AfterUpdate of the checkbox control:

If Me.chkMyCheckbox = True Then
Me.txtMyTextbox.Enabled = True
Else
Me.txtMyTextbox = Null
Me.txtMyTextbox.Enabled = False
End If

in the OnCurrent event of the form:

If Me.chkMyCheckbox = True Then
Me.txtMyTextbox.Enabled = True
Else
Me.txtMyTextbox.Enabled = False
End If

Note that the technique of also enabling and disabling of the textbox
control will work in Single view only, not Continuous view.
 
A

Armen Stein

Are both the checkbox and textbox bound to the same thing in my table?


No - you would need a Yes/No field (e.g. SendEmailFlag) and a text field
(e.g. EmailAddress). Each control on the form is bound to its
corresponding field in the table.

I'm assuming that you want to ask the user whether they would like to
send an email, and if so, enable the email address field so they can
enter the address. Both the choice whether to send an email and the
actual address can be stored in your table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top