PDA

View Full Version : Is it possible to populate empty fields based on a tick in a checkbox?



wedd
10-21-2010, 08:12 AM
Hi, I was wondering if it was possible to tick a check box and based on the box being checked would populate empty fields. Can this be done? If so, how can this be done? If possible do you have any sample code or do you know of any websites that may have vba code to do this...


A keen learner of vba


Thanks for your solutions:clap:

Imdabaum
10-21-2010, 08:44 AM
Yes. On the AfterUpdate Event, set the values.
Using select case statements, if then statements or separate AfterUpdateEvents for each checkbox.

Go to design mode- click the checkbox, if it's part of a group then you can easier select the group and change the afterupdate event based on the group value.(If you have a group box and checkboxes/radio buttons that provide its value then only one afterupdate event is needed and it can save you some coding.)

Create a Sub SetValues() and then Do based on case. If you use a groupbox, then

Select Case Me.GroupBoxName.Value
case 1
Me.TxtField1 = "blah"
Case 2
Me.TxtField1 = "blahdiblah"
Case 3
Me.TxtField1 = "Blahdiblahblahblah"
End Select

Imdabaum
10-21-2010, 09:05 AM
That's my proposal.

As I said, if you use a group box it reduces a lot of code.