Select Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I tie the results of an unbound object such as check bock to a bound
object? I would like for bound information to appear if the check box is
checked. Thanks!
 
Without using the terms "object" or "bound", describe what you need to do.
In other words, what real-world result do you seek? A check box is a
control, not an object. A bound form (a form is a database object) has a
table (or query) as its record source. A control such as a text box or
check box on that form may then be bound to a field in the record source
table. If a text box is bound to a table field, what you type in the check
box will be stored in the field to which that text box is bound. If a check
box is bound to a yes/no field in the table, checking the box will cause Yes
(or 0, which is the equivalent of Yes in a Yes/No field) to be stored in
that Yes/No field. Checking a box can cause other things to happen (things
to be hidden or unhidden, for instance) if you have added the correct code
to the check box's After Update event.
 
Thanks! I understand what you are saying but maybe I need explain what I am
trying to do. I would like the user to check the box so that information in
another field will be displayed or if uncheckecd it should be blank.
 
What information would that be? Is the text box bound? In general, the
After Update event of the check box would be something like:

If Me.chkCheckBox = 0 Then
' Something happens
Else
' Something else happens
End If

I can't be more specific because I don't know if you are trying to populate
a field, or if you just need words to appear in an unbound text box, or if
you want to hide the text box completely, or what.
 
I would like upon selection to show information from a field in a query,
otherwise let that query field remain blank.
 
In the AfterUpate of the Checkbox, set the control's visible property to
either true or false.

Private Sub MyCheckBox_AfterUpdate()
Me.MyTextBox.Visible = Me.MyCheckBox
End Sub

HTH,
Brian
 
To add to what Brian wrote, if you want the text box to show text only if
the check box is checked, make the text box unbound. In the check box After
Update event you can set the control source for the text box:

If Me.chkCheckBox = True Then
Me.txtYourText = Me.YourText
Else
Me.txtYourText = ""
End If

chkCheckBox is the name of the check box, txtYourText is the name of the
unbound text box, and YourText is the name of the query field. You will
need the same code in your form's Current event.

I believe I erred earlier in saying you would use 0 for True. I believe -1
is true in a yes/no field. I just use True or False most of the time.

You could also adapt this code to make a text box visible or not, as Brian
outlined.
 
Thanks Brian!! Those instructions worked out great and it enable me to
understand BruceM's suggestions, which actually helped make things work even
better. Thanks BruceM!!
 
Back
Top