[AccessD] Raising events from a subform and sinking them in the parent form

Charlotte Foust charlotte.foust at gmail.com
Tue Mar 25 14:09:07 CDT 2014


That's pretty much what I wound up doing, Shamil.  Thanks.

Charlotte


On Tue, Mar 25, 2014 at 7:19 AM, Salakhetdinov Shamil <mcp2004 at mail.ru>wrote:

>  Hi Charlotte --
>
> WithEvents could be used here, I'm sure, but I'd not recommend to use it
> :)
>
> I'd code:
>
> Parent form:
> =========
>
> Private Sub Form_Load()
>       Me.{{subform control name}}.Form.InitSubform("{{Initial record
> key}}")
> End Sub Public Sub LoadRecord(ByVal recordKeyValue As String)
> ' TODO: load parent form record
> End Sub
>
>
> Subform:
> =======
>
> Public Sub InitSubForm(ByVal recordKeyValue As String)
>      selectRecord(recordKeyValue)
> End Sub
>
> Private Sub txtSearchValue_Change()
>        If (Nz(txtSearchValue.Text, "") <> "") Then
>             selectRecord(txtSearchValue.Text)
>        End if
> End Sub Private Sub selectRecord(ByVal recordKeyValue As String)
>      Me.Parent.LoadRecord(RecordKeyValue)
>      ' TODO: ... select record in subfom
> End Sub
>
> -- Shamil
>
> Tue, 25 Mar 2014 06:54:25 -0700 from Charlotte Foust <
> charlotte.foust at gmail.com>:
> >No you didn't, and I also abandoned them in the solution I came up with.
> > So far I haven't had any luck with WithEvents in 2013.  The sink never
> >seems to recognize the raised event, but I haven't been using custom
> >classes.
> >
> >The subform isn't bound to the parent form.  It uses a recordset for
> >navigation (it allows a text entry to search for another record) and when
> >it finds a match, it tells the parent form to load that record.  The
> parent
> >form in turn passes a key to which record the subform should be pointing
> to
> >when the form first loads.
> >
> >Charlotte
> >
> >
> >On Mon, Mar 24, 2014 at 3:39 PM, Salakhetdinov Shamil < mcp2004 at mail.ru>wrote:
> >
> >>  Charlotte --
> >>
> >> But I haven't proposed to use WithEvents, have I? :)
> >>
> >> <<< and allowed the subform to search in it's (snapshot) recordset for
> the
> >> desired record>>>
> >> Well, subform loads before parent form but how does your subform get
> >> search/filtering criteria to search its (snapshot) recordset by?
> >>
> >> -- Shamil
> >>
> >> Mon, 24 Mar 2014 15:27:29 -0700 from Charlotte Foust <
> >>  charlotte.foust at gmail.com >:
> >> >Because I was determined to make it work the other way, of course!  LOL
> >> >
> >> >Actually, I eventually worked out that way of doing it so that the
> people
> >> >who will be maintaining it are more likely to understand than
> WithEvents.
> >> > I added a loaddata routine to the parent form, removed any
> master/child
> >> >links on the subform, and allowed the subform to search in it's
> (snapshot)
> >> >recordset for the desired record and pass the key into the loadData
> >> routine
> >> >on the parent form.  It isn't elegant but these guys are engineers, not
> >> >database developers, and they'll be able to understand this.
> >> >
> >> >Charlotte.
> >> >
> >> >
> >> >On Mon, Mar 24, 2014 at 1:48 PM, Salakhetdinov Shamil <
> mcp2004 at mail.ru >wrote:
> >> >
> >> >>  Hi Charlotte --
> >> >>
> >> >> Why not just define a
> >> >>
> >> >> Public Sub ProcessEvent(ByVal eventName As String, ParamArray
> >> eventArgs())
> >> >>     MsgBox eventName & ", Params Count = " & UBound(eventArgs) + 1
> '
> >> test
> >> >> End Sub
> >> >>
> >> >> in the Parent form and call it from a  subform like that
> >> >>
> >> >> Me.Parent.ProcessEvent "Test event", "Prm1", 123.45  ' test call
> >> >> -- Shamil
> >> >>
> >> >>
> >> >> Mon, 24 Mar 2014 13:23:54 -0700 from Charlotte Foust <
> >> >>  charlotte.foust at gmail.com >:
> >> >> >I know I've done this before but it probably required a class,
> which I
> >> >> >hesitate to use in this app.  Has anyone else had problems raising
> and
> >> >> >sinking events between forms in Access 2010/2013?
> >> >> >
> >> >> >Charlotte
> --
> 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