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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help With Checkboxes and text box 2

Status
Not open for further replies.

simpsondm

IS-IT--Management
Jan 14, 2003
21
US
Need help making check boxes work. Here’s my problem I have 4 check boxes named WSG, LSG, BSG, SSG. The fields for these check boxes are named the same. I then have a text box named Unit and the field in the table is named Unit.

What I’m trying to do is if one of check boxes is checked (true) such as LSG then it will automatically fill in the Textbox LSG in turn put it into my Unit field in my table.

As you can tell from this question I am very new to Access and Databases in general so any help would be greatly appreciated.

Thanks
DMS
 
What you need is a line of code to set the value of the text box to the appropriate value after one of the check boxes is checked:

Put this in the After Update event of each check box:

Me.Unit.Value = "WSG"

You need to change the 'WSG' to SSG, or whatever, depending on the check box.

To be pure, you should add error trapping, but this will work alone. Also, you probably want to use an option group instead of standalone check boxes, so that only one option can be 'checked'. If you like the check boxes, then you need to add code that will uncheck any other boxes once a new box is checked.

- - - -

Bryan
 
Byan,

Thank you for your help it worked. But I have another question what do you mean by (To be pure, you should add error trapping, but this will work alone. Also, you probably want to use an option group instead of standalone check boxes, so that only one option can be 'checked'. If you like the check boxes, then you need to add code that will uncheck any other boxes once a new box is checked.)

After running it I did find that I need away to keep from being able to check the other boxes and I noticed that the last checked boxes stays in the field until you check another box is their away to clear the box when you start another records.

Anyway again that you for your help.
 
if you want to clear the checkboxes when you add a nw record set the defaultvalue of that checkbox to 0 (you find the defaultvalue propertie in the data tab)
Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
You could try using a group of option buttons or radio buttons instead that way you can only select one.

Transcend
[gorgeous]
 
D24:

Error trapping . . this is code that will identify any error that takes place while the code is running. You'll probably never need this, but if you want to add it, take a look at the code behind some objects that Access creates with a wizard (like a command button) for examples. Look for a line that starts with 'On Error GoTo Err_whatever'.

An Option Group group is a frame that can contain check boxes, toggle buttons, and option buttons on a form, report, or data access page. You use an option group to present alternatives from which the user can select a single option. You can create a group using the wizard tool and the option group tool (xyz with the box) on the toolbar.

See Chrissie's post for making sure not boxes are checked on a new record.
- - - -

Bryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top