A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Reusable code forms help for a newbie please!



 
 
Thread Tools Display Modes
  #1  
Old April 26th, 2008, 05:06 PM posted to microsoft.public.access.forms
MattieG[_2_]
external usenet poster
 
Posts: 2
Default 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  
Old April 26th, 2008, 05:49 PM posted to microsoft.public.access.forms
Wolfgang Kais[_3_]
external usenet poster
 
Posts: 68
Default 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  
Old April 26th, 2008, 11:38 PM posted to microsoft.public.access.forms
MattieG[_2_]
external usenet poster
 
Posts: 2
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.