Auto Populating Check Boxes

DAyotte

Board Regular
Joined
Jun 23, 2011
Messages
84
I have a form with a combo box. Once you select a record out of that combo box, there are 21 fields of information on that form that fill out with all related information to that record. However, I have 2 check boxes that I would like to auto-populate depending on the record.

Some records could be 'type A'
Some records could be 'type B'
Records cannot be both A and B
However it is possible, and most are null (neither A or B)

In the table that this form reads off of, there are two columns of information. Each record that is an A, has "A" in that specified column, and same for "B".

:huh:Hopefully this all makes sense.:huh:
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I think a simple If statement might work but I do have one question first. Is this an informational purpose only checkbox, or something that can be changed at some time in the future? Think carefully because this decision has a direct impact on how to code it.

If you add a record, would you want someone to be able to select a checkbox to store in the table that it is a merger or (hostile) takeover? (j/k :) )
 
Upvote 0
I'd be informational only, lol.

These mergers/ takeovers of complete hospitality... ( :cough: ) were more than a year ago, so this information won't change.
 
Upvote 0
Ok, the easy way of doing it is like this. You need to create two checkboxes (Check1 and Check3 for this example). Also, have the field that contains the value (the "A" or "B") that is bound on the form as well, but you make it's visible property = False.


Then, in the On Current event of the form, You will have code similar to this:
Code:
Select Case [fieldNameThatContainsValue] ' bound field name
    Case Is = "A Value"
        Me.Check1.Value = True
        Me.Check3.Value = False
    Case Is = "B Value"
        Me.Check1.Value = False
        Me.Check3.Value = True
    Case Else
        Me.Check1.Value = False
        Me.Check3.Value = False
End Select

That should do the trick. I tested it out so all you need to do is change the values of the cases, checkboxes, and the bound field.
 
Upvote 0
Ok, when I made the table, the "type A" column is separate from the "type b" column... so I tried this:

Code:
Select Case [type a] ' bound field name
    Case Is = "a"
        Me.Check4.Value = True
        Me.Check6.Value = False
    Case Else
        Me.Check4.Value = False
        Me.Check6.Value = False
End Select

Select Case [type b] ' bound field name
    Case Is = "b"
        Me.Check4.Value = False
        Me.Check6.Value = True
    Case Else
        Me.Check4.Value = False
        Me.Check6.Value = False
End Select

but it's not working - the boxes are still grayed out. (obviously I have the corresponding information to "type a", and "type b" both corrected on my side.)
 
Upvote 0
The only things that should be bound are the textboxes bound to the fields that show "A" and "B" from the table. Set the Control Source to whatever field in the table populates in the drop down.
 
Upvote 0
There is no text boxes for those. Only the check boxes. I do have them bound... let me try without it.
 
Upvote 0
negative... still not working.

so both check boxes are unbound. I still have the code as I showed you in there.
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top