PDA

View Full Version : VBA: How to make a form that calculate automatically w/ Checkboxes



bi0hazard
06-15-2011, 09:02 AM
Hi,

I'm new on this forum, but I'm ain't in the VBA universe.

I actually have this Word Document with this form:
https://lh4.googleusercontent.com/-_FhRPGc9DGA/TfjWkELfp5I/AAAAAAAAHUw/fc4mJ_-60Xg/s640/printscreen.JPG


I want to elaborate a "Function" so when the user enters a number (integer) into the "# of set" FormField, the "Required sample size" updates itself.
If the associated checkbox goes to false statement, it resets the associated formfield.

Do you guys have some brilliant ideas on how to make a function like that? As you can see, I have a lot of FormField. I would like to make a function to input a X and then calculate an Y to write it into a designed Formfield.

I don't know if I'm clear enough, my native language isn't english :P

Thanks for help!

macropod
06-16-2011, 05:46 PM
Hi Bi0hazard,

Your checkbox and '# of sets' formfields would require an on-exit macro to trigger the updating. With careful coding, they could probably all use the same on-exit macro. From what you've posted, it seems your on-exit macro could simply go through all relevant rows in column A and, if the checkbox for a given row is checked, multiply the # in column E by your constant for that row to calculate the sample size.

bi0hazard
06-17-2011, 11:01 AM
Hi,

Finally, I've change the way my form is made since using FormField are likely to be harder to work with vba coding.

I've replaced them with TextBox instead. It's way easier to work with.

Now i'm facing a new issue. Let me explain in details:

I've a "Total" TextBox which calculates each TextBox into one.
(Textbox1 to Textbox37)

Let's say someone enters "11" in Textbox1. The TotalTextBox will display eleven. Let's say that same person didn't want to enter "11" but "1". If he erases 1 x "1", the TotalTextBox will add "1" again... Damn!

I posted my file. How do I manage that? I though about updating the Textbox field after it lost Focus, but I'm not sure.

bi0hazard
06-20-2011, 04:23 AM
Bump! I need a little hint!