PDA

View Full Version : Solved: Userform check boxes and controling them.



pingwin77
12-03-2008, 02:53 PM
I have a message box that pops up when a button is pushed. The operator chooses "YES" or "NO." When "YES" is clicked, I need a user form to open that has the following stuff in it: (the [ ] represents a check box in the user form.)

[ ] The stated uncertainty of the measured values has not been taken into account for the pass / fail indicators.

[ ] *An asterisk in the scope column indicates that those test results are not covered by our current A2LA accreditation.

[ ] This Certificate of Inspection includes additional pages of inspection results supplied electronically to the customer.

[ ] This Certificate of Inspection was completed using a customer report template.

[ ] Temp [text box activates if TEMP is checked]

[ ] Humidity [text box activates if HUMIDITY is checked]

[ ] Additional Notes: [large text box activates if ADDITIONAL NOTES: is checked]


As these boxes are checked i need them to be added to specific cells in my workbook so they can be added to the comments pages of my report and condensed so that there is no space between them if some of the middle check boxes or left blank.

I can make the user form in the VBA editor but have no idea how to get the check boxes to interact with the workbook. I also don;t know how to get the userform to pop up when the user clicks "YES" on the message window.

Please let me know if you have any suggestions or questions. Thanks in advance!

lucas
12-03-2008, 03:04 PM
Why not use a userform to call the next userform instead of a messagebox.......

for the checkbox something like this when the button is clicked:

Private Sub CommandButton1_Click()
If CheckBox1.Value = True Then ActiveSheet.Range("D6").Value = "test"
End Sub

pingwin77
12-03-2008, 03:36 PM
I have some notes in that box that my operators need to see before they choose YES or No. Can that be done in a separate userform as well?

as for the VBA, do I just create a new module and have a sub for each check box or can they all go into one sub?

lucas
12-03-2008, 05:33 PM
I have some notes in that box that my operators need to see before they choose YES or No. Can that be done in a separate userform as well?


Absolutely, use a label......see attached example.


as for the VBA, do I just create a new module and have a sub for each check box or can they all go into one sub?
No, the code I provided needs to go in the code for the userform....specifically in the click event of the button on the userform.....see attached example.

pingwin77
12-04-2008, 07:22 AM
I got that going so far. Thanks!

2 more questions:

1. How do i get the data to past somewhere other than the activesheet? I need to have the data past to a different worksheet in my book.

2. How do I get the data from the text box to go to the same page as the other data but only when the corresponding check box is selected? And if possible, mainly to look nicer, is there a way to have the text box active (allow data to be entered) only when the check box is selected?

lucas
12-04-2008, 10:09 AM
1. How do i get the data to past somewhere other than the activesheet? I need to have the data past to a different worksheet in my book.

Fully qualify where you want it to go.....the following puts it in sheet 2

If CheckBox2.Value = True Then ActiveWorkbook.Sheets("Sheet2").Range("D7").Value = "test2"
If CheckBox2.Value = True Then ActiveWorkbook.Sheets("Sheet2").Range("D7").Value = "test2"




2. How do I get the data from the text box


What textbox? First time you've mentioned it. It's done the same way....

to disable the textboxes use this in the checkbox click event....
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then TextBox1.Enabled = True
End Sub