Hi,
how to declare an integer variable (calculated into a userform) to allow it to pass from a userform to a module?
Thank you
Hi,
how to declare an integer variable (calculated into a userform) to allow it to pass from a userform to a module?
Thank you
Try declare the variable as public variable
What does the code in the module do?
Are you calling a sub in the module from the userform?
If posting code please use code tags, see here.
I've tried to declare it as Public but in a userform doesn't work.
The code in the userform takes 3 values from 3 different textboxes (day, month, year) and define the date as general number. I need to use this number in another module. If the user insert something wrong a an error message is displayed and the .Redoaction command allows the user to try again. If the the input it's correct the userform code will run the Sub placed into the Module.
declare it as public in a normal module, or pass it directly to the routine you call from the form
Josie
if at first you don't succeed try doing it the way your wife told you to
You can pass the date to the other sub like this, which would go in the userform.
The other sub would need to be adjusted to take the argument.![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Thank you Norie,
I'm going to have a go.
I know it sounds really really bad but for the moment I've just written my variable in a hidden label caption. In the sub I'm "calling" the value from the label caption and I'm converting it into a number again. At least it works..
I was actually going to suggest something like that but didn't know how you were calling the form or the sub.
Actually, do you need a hidden label? Can't you take the values directly from the textboxes on the form?
It's just a label without caption. As soon as I write the new caption I hide the userform.
Actually the first attempt was to run the sub directly in the userform as part of its code, which sounds like your idea.
But for the first time (and I don't know why) if an error was found and the vbCritical messagebox displayed, the code was simply "passing through" the Me.Redoaction running in any case the rest of the code. So the user didn't have the chance to correct the mistake. It sounds silly but that's why I've decided to separate Module and Userform.
If you can get the caption of a label from the userform you can get the values in the year, month, day textbox too.
By the way, I wasn't suggesting having the sub in the userform code, thought that might be a good idea.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks