[AccessD] More Class lectures?

jwcolby jwcolby at colbyconsulting.com
Thu Feb 12 18:46:36 CST 2009


Arthur,

OK, so now that you have a message class, dimension a variable WithEvents in both of the form's headers.

Private WithEvents fclsMsg As clsMsg


In the orders form build an event sink for the clsMsg:

Private Sub fclsMsg_Message(varFrom As Variant, varTo As Variant, varSubj As Variant, varMsg As Variant)
     If varFrom = "frmCustomers" Then
         If varTo = "frmOrders" Then
             If varsubject = "CustomerID" Then
                 'Sync frmOrders to CustomerID
             End If
         End If
     End If
End Sub

Notice that the sender (frmCustomer) has to call the clsMsg.Message and pass in a string with its 
name in From, the order form's name in To, "customerID" in varSubject, and the CustomerID itself (a 
long?) in varMsg.

Private Sub Form_Current()
Dim lngCustomerID
     lngCustomerID = 1
     fclsMsg.Send Me.Name, "FrmOrders", "CustomerID", lngCustomerID
End Sub


John W. Colby
www.ColbyConsulting.com


Arthur Fuller wrote:
> I've done that with the NotInList event too. I did it with a function that
> accepts the name of a form, but a class is a cleaner way to go.
> 
> What I was thinking here is that I could have a customer form open and and
> orders+details form open at the same time, and that navigating on the
> customer form would automatically refresh the orders form, even though they
> are separate forms. The same thing could be done with the order details
> subform and the products form.
> 
> Arthur
> 
> On Thu, Feb 12, 2009 at 4:43 PM, jwcolby <jwcolby at colbyconsulting.com>wrote:
> 
>> Yep, that will work just fine.  What is the implementation idea?
>>
>> I have a behavior that I actually have embedded in my framework where the
>> dbl-Click event of the
>> combo can cause a list form to open, navigate to the record in the combo,
>> or if the combo item is
>> "not in list" opens the list form in Add mode.
>>
>> Suppose that you have something being displayed in a combo box. Perhaps a
>> name / SSN for a person.
>> A user is trying to add people in a form using that combo, but notices that
>> the name / ssn in the
>> combo box appears to be correct but the SSN is off by a digit (just an
>> example scenario).  The user
>> can select that person, then dbl click in the combo.  The combo class has
>> to have been fed a form to
>> open in case of the dbl click.  If it has, then the combo opens the form.
>>  Since the PKID is in
>> column 0 of the combo, the combo class "passes in" the PKID of the person
>> selected in the combo.
>>
>> The form as it opens, grabs the PKID and moves to that PKID and places the
>> form into Edit mode.
>> Voila, instant edit of exactly the correct record in another form.
>>
>> John W. Colby
>> www.ColbyConsulting.com <http://www.colbyconsulting.com/>
>>
>>
>>  Arthur Fuller wrote:
>>> I've gone all the way with you, JC, and this weekend I plan to try an
>>> experiment bearing on the "Sinking Events in Multiple Places" concept --
>>> specifically, two related forms open and navigation on one causes
>> parallel
>>> navigation on the other, so they stay in synch. Seems like a perfect
>>> application of this concept.
>>>
>>> Arthur
>>  --
>> 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