Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple problems, I think.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
1) How do I get a check box to uncheck when click on a textbox?

2) What's the best way to store values from a listbox (with the ability to select more than one option) so that I can use queries on them later?

I know I've been asking for the answers to these for a while, but I can't get it to work on my own.
 
For the first one, it sounds like you'd need to do an if statement. That is, if certain criteria is met, then the checkbox would be checked or unchecked. As an example, this one makes a text field visible and inserts the current date into the field.

Private Sub chkOnHold_AfterUpdate()
On Error GoTo ErrorOnHold

If Me.chkOnHold = True Then
txtOnHold.Visible = True
txtOnHold.Value = Date

Else

txtOnHold.Visible = False

End If

ExitOnHold:
Exit Sub

ErrorOnHold:

MsgBox Err.Description
Resume ExitOnHold

End Sub

Linda Adams
Visit my web site for writing and Microsoft Word tips: Official web site for actor David Hedison:
 
use the textbox's OnClick or OnMouseDown events, if that's what you want. or use the textbox's OnGetFocus event if you want your code to fire any time the textbox gets the focus (even by tabbing to it).

Then:
Code:
    'uncheck the checkbox, ignoring former value
     chkMyCheckBox = False[\code]
inside the event handler will do it for you!

If you want the checkbox to toggle state instead of just unchecking no matter what, use:
[code]    toggle the checkbox
     chkMyCheckBox = Not chkMyCheckBox[\code]

(CheckBox default poperty is the .Value property, so I didn't reference it explicitly above.)
 -- C Vigil  =)
(Before becoming a member, I also signed on several posts as
"JustPassingThru" and "QuickieBoy" -- as in "Giving Quick Answers")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top