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:
 
Yes, both checkboxes need to remain unbound, but go back to the my original response about having a bound text field for the "A" and "B" to appear on the form. These will be hidden later, but the code needs to refer to them.
 
Last edited:
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Still a negative. Code remains the same. I have 2 text boxes on the bottom of the form (visible at this time) both bound to their corresponding fields on the table. Both are named identical to the fields they correspond to as well.
 
Upvote 0
Alright, shoot me what you have as your edited code, the names of the check boxes, and the names of the bound textbox fields.
 
Upvote 0
code:
Code:
Select Case [NameA] ' bound field name
    Case Is = "NameA"
        Me.Check4.Value = True
        Me.Check6.Value = False
    Case Else
        Me.Check4.Value = False
        Me.Check6.Value = False
End Select

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

"Type A":
check box - Check 4
text box - NameA

"Type B
check box - Check 6
text box - NameB

idk if I can actually put the company info in here w/o violating policy... which is the reason for the vagueness.
 
Upvote 0
No that's cool, I understand. I have the same problem at times because I am working at a health insurance provider. :)

I had to modify the code from a Select Case to a If...then. I did this because (and I missed this earlier) the second select case essentially negates the first select case. This if..then takes care of that. Try this and see what you get, if it still doesn't work, let me know. I basically worked up a sample db to test this out on and I will send that to you so you can see how it works and step through the code.
Code:
Private Sub Form_Current()

If [NameA] = "NameA" Then '[NameA] is bound textbox control. "NameA" is the actual text in the record.
    Me.Check4.Value = True 'checkbox for A
    Me.Check6.Value = False ' checkbox for B
    Exit Sub ' don't want the later half of code to execute
End If
If [NameB] = "NameB" Then '[NameB] is bound textbox control. "NameB" is the actual text in the record.
    Me.Check4.Value = False
    Me.Check6.Value = True
    Exit Sub ' don't want the later half of code to execute
Else
    Me.Check4.Value = False
    Me.Check6.Value = False
End If

End Sub
 
Last edited:
Upvote 0
I'm really sorry... but it's still not working for me.
Code:
Private Sub Form_Current()

If [NameA] = "NameA" Then '[NameA] is my text box name, and "Name A" is what the field in the table contains to confirm that it is "Type A".
    Me.Check4.Value = True 'checkbox for A
    Me.Check6.Value = False ' checkbox for B
    Exit Sub ' don't want the later half of code to execute
End If
If [NameB] = "NameB" Then '[NameB] is my text box name, and "Name B" is what the field in the table contains to confirm that it is "Type B".
    Me.Check4.Value = False
    Me.Check6.Value = True
    Exit Sub ' don't want the later half of code to execute
Else
    Me.Check4.Value = False
    Me.Check6.Value = False
End If

End Sub

I even checked all of the spelling, etc.
 
Upvote 0
In the Events properties of the Form, you do have On Current selected to go to Event Procedure, correct? Make sure that Form is selected from the drop down list, and not some other control on the form.

Also, step through your code. Bring up the VBA and in the margin next to the code (probably an active line like the first If statement), click. A brown dot will come up and that means anytime your code runs thought that section, it will stop for you to step through. If you navigate to a new record and the code never stops you, it means it is not triggering.

Try those things, and PM your email address. I will send you the mock up db that I built to work this code out.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

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