[AccessD] Doin the class thing - frmDNDText

David A Gibson davidalangibson2010 at gmail.com
Thu Feb 7 15:17:16 CST 2013


3rd

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John W Colby
Sent: Thursday, February 07, 2013 9:30 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Doin the class thing - frmDNDText

The code for the form's class is simple.  In the form's header we create an
instance of the class for every text box we want to handle.  Notice that I
already have a disclaimer that this is the 'quick and dirty' way of doing
things.  This works but there is a better way which we will discuss once you
have absorbed this method.

'
'The quick and dirty way to do this
'
Private cDNDTxt2 As clsDNDText
Private cDNDTxt4 As clsDNDText
Private cDNDTxt6 As clsDNDText

In the form's Open event we initialize each of the instances of this class,
setting the pointer to each instance using the new keyword and then passing
in a pointer to one of the text boxes in the mInit method.

Private Sub Form_Open(Cancel As Integer)
     Set cDNDTxt2 = New clsDNDText
     cDNDTxt2.mInit Text2

     Set cDNDTxt4 = New clsDNDText
     cDNDTxt4.mInit Text4

     Set cDNDTxt6 = New clsDNDText
     cDNDTxt6.mInit Text6

End Sub

and finally, not included in the original post we want to cleanup in the
form's close event

Private Sub Form_Close()
     Set cDNDTxt2 = Nothing
     Set cDNDTxt4 = Nothing
     Set cDNDTxt6 = Nothing
End Sub

How much simpler can it be?

Let's discuss this and then we can move on to the next step.

--
John W. Colby

Reality is what refuses to go away
when you do not believe in it

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list