If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Reusable code forms help for a newbie please!
Hi
Im hoping someone can give me some guidance on this problem i want to try and solve. I basically have bout 6 or 10 forms with a lot of common form validation for the combo boxes dates/text boxes etc not to be null etc. This code for the validation is the same on every form and i was looking to put it in to a common module to help with amintainability etc. The problem i am having is that all the validation is something like If Me.PaymentID Is Null Then.... prompt user to complete details etc. If I put this code into a common module the Me. doesnt seem to work. Do I need to use Screen.ActiveForm in the common module or do I need to pass in the form as a variable? I hope that makes sense but any help would be appreciated. Mattie |
#2
|
|||
|
|||
Reusable code forms help for a newbie please!
Hello Mattie.
"MattieG" wrote: Hi Im hoping someone can give me some guidance on this problem i want to try and solve. I basically have bout 6 or 10 forms with a lot of common form validation for the combo boxes dates/text boxes etc not to be null etc. This code for the validation is the same on every form and i was looking to put it in to a common module to help with amintainability etc. The problem i am having is that all the validation is something like If Me.PaymentID Is Null Then.... prompt user to complete details etc. If I put this code into a common module the Me. doesnt seem to work. Do I need to use Screen.ActiveForm in the common module or do I need to pass in the form as a variable? I hope that makes sense but any help would be appreciated. I think that using Screen.ActiveForm is not the best way to accomplish you task, because it will not work with subforms and what if the user is ast enough to change the active form? I suggest to either pass a reference to the form to your validation procedure, for example: Private Form_BeforeUpdate(Cancel As Integer) GlobalValidation Me End Sub An alternative is using the CodeContextObject in the global module to reference the object (form or report) that as called the code. -- Regards, Wolfgang |
#3
|
|||
|
|||
Reusable code forms help for a newbie please!
Thanks wolfgang.
I will try and figure out how to do that, im sure it wont be too dificult. Thanks for pointing me in the right direction. Mattie |
Thread Tools | |
Display Modes | |
|
|