[AccessD] Refreshing open forms when something changes

Stuart McLachlan stuart at lexacorp.com.pg
Mon Jun 20 16:31:49 CDT 2011


I generally just use Forms!MyFom.Requery or Forms!MyForm.MyControl.Requery.

Or am I missing something?

-- 
Stuart


On 20 Jun 2011 at 10:11, jwcolby wrote:

> Have you ever needed to refresh queries, lists or the form itself when
> something happens on another form entirely?  How do you do this?
> 
> I have a form where a user can open a volunteer form and select cities
> that (s)he wants to see meetings in.  Selecting cities in a subform on
> that volunteer form causes two lists up in the volunteer form to
> requery.  It may also affect combos in subforms on an already open
> frmInmate and so those combos need to requery.
> 
> Being a class sort of guy, my solution is to have a message class. 
> The message class can raise an event.  The message class emulates an
> email with a From, To, Subject and body.
> 
> So I set up a global pointer to an instance of the message class which
> is initialized when the program starts.  Now a message "channel" is
> available for any process to send a message.  Processes that want to
> send a message basically calls a method
> 
> cmsg.Send "MyName", "WhoThisIsGoingTo", "MySubject"
> 
> The form which needs to receive the message dimensions a message class
> withevents and sinks the Send event.
> 
> private withevents mcMsg as dclsMsg
> 
> In the Load of the form it grabs a pointer to the global message class
> so it can sink the events.
> 
> private sub Form_Open(Cancel as Integer)
>  set mcMsg = cmsg()
> end sub
> 
> And now sinks the event and does something with it:
> 
> 
> private sub mcMsg_Message(varFrom as variant, varTo as variant,
> varSubject as variant, varMsg as variant)
> 
>  if VarFrom = "MyName" then
>   if VarTo = "WhoThisIsGoingTo" then
>    if VarSubject = "MySubject" then
>     'Requery the combo
>     MyCombo.requery
>    endif
>   endif
>  endif
> end sub
> 
> The reason for doing all of this is that if the form is open it
> requeries the combos, if it is not nothing happens (in this form). 
> Any and all forms which need to requery something can subscribe to
> this event (message) and requery whatever each form needs to requery
> when the list of cities changes.
> 
> I have discussed the message class previously but I will email the
> class in a couple of hours.
> 
> -- 
> John W. Colby
> www.ColbyConsulting.com
> -- 
> 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