[AccessD] Referencing forms as objects

Charlotte Foust charlotte.foust at gmail.com
Sat Aug 6 11:44:06 CDT 2011


IIRC, this has always been an issue, particularly since the speed of a
double click is set by the user.  The Click event always happens.  Double
click is problematic.  If you're trapping the Click event, you won't be able
to reliably trap a double click because the Click event will always fire
first.  If you don't tap the Click, then double click can be trapped.

Charlotte Foust

On Sat, Aug 6, 2011 at 6:49 AM, Dan Waters <df.waters at comcast.net> wrote:

> Other people have done that.  I'm starting to get the impression that I
> won't be able to use a Click event and a DoubleClick event for the same
> control without a mechanism in the click event to discriminate between the
> two.
>
> This is an example:
>
> http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/36f03b
> a0-f7d9-4f94-9565-1453e24cf4ee/<http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/36f03ba0-f7d9-4f94-9565-1453e24cf4ee/>
>
>
>
> Dan
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William Benson
> (VBACreations.Com)
> Sent: Monday, August 01, 2011 1:21 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Referencing forms as objects
>
> Can you do something with a click event and a timer? i.e., click event
> starts a timer, and if another click event occurs while timer is under a
> certain increment from there, treat the second click like a double-click?
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
> Sent: Monday, August 01, 2011 12:44 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Referencing forms as objects
>
> Thanks John!
>
> I will try this.  First, I have to solve the problem of no double-click
> event available for a combobox on a winform in visual studio.
>
> Dan
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
> Sent: Monday, August 01, 2011 11:29 AM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Referencing forms as objects
>
> Dan, here ya go.
>
> Notice that in order to do this I had to:
>
> 1) Dimension a form object WithEvents in the header of the calling form.
> This tells the calling form that it has a class (form in this case) that
> may
> be raising events.
>
> 2) Build one or more event sink.  This takes the object dimensioned in step
> 1 above and sinks one (or more) events that that object is raising.
>
> 3) In the object raising the event I have to define the event that it will
> raise in the header of that object (the modal form in this case).  This
> tells the compiler that this object is capable of raising at least one
> event.
>
> 4) Raise the event wherever needed.  This actually causes the event to fire
> and transfers data of event parameters are defined.
>
> These 4 steps are always required to use events.
>
> Only classes can raise events.  Only classes can sink events.  Forms are
> classes, ergo forms can sink events (we already know that) but forms can
> also raise events.
>
> In the calling form:
>
> 'Header
> '
> 'Define an object (a form) that we are going to sink events for '
> Public WithEvents frmDiaryExtensionReason As Form_frmDiaryExtensionReason
>
> '
> 'event sink
> 'This is where the data comes back from the modal form '
> Private Sub frmDiaryExtensionReason_evExtendDate(dte As Date,
> strExtendReason As String)
>
>        txtExtendReason.Value = strExtendReason
>        txtExtendDate.value = dte
>        me.dirty = false
> End Sub
>
> 'The combo that causes the unbound form to open Private Sub
> cboCloseReason_AfterUpdate()
>     Select Case cboCloseReason.column(0)
>     Case 2      'Rescheduled - needs to be copied then the original closed
>         DoCmd.OpenForm "frmDiaryExtensionReason"
>         Set frmDiaryExtensionReason = Forms("frmDiaryExtensionReason")
>
> In the modal form:
>
> 'this defines the event that the form will raise '
> Public Event evExtendDate(dte As Date, strExtendReason As String) '
> Private blnValidDate As Boolean
>
> Private Sub cmdCancel_Click()
>     DoCmd.Close acForm, Me.Name
> End Sub
>
> Private Sub cmdExtendDate_Click()
>     If blnValidDate Then
>         'Validate that they put something in the comment
>         If Len(txtExtendReason.Value) Then
>             '
>            'This is where the event is raised and data sent of to someone
> else
>             RaiseEvent evExtendDate(txtExtendDate.Value,
> txtExtendReason.Value)
>             DoCmd.Close acForm, Me.Name
>         Else
>             MsgBox "No reason was entered"
>             txtExtendReason.SetFocus
>         End If
>     Else
>         MsgBox "The date entered is not valid"
>         txtExtendDate.Value = ""
>         txtExtendDate.SetFocus
>     End If
> End Sub
>
> 'Validate that the entry is a date
> Private Sub txtExtendDate_AfterUpdate()
> Dim dte As Date
>     On Error Resume Next
>     dte = txtExtendDate.Value
>     If Err Then
>         blnValidDate = False
>     Else
>         blnValidDate = True
>     End If
> End Sub
>
>
> John W. Colby
> www.ColbyConsulting.com
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
>
>
> Website: http://www.databaseadvisors.com
>
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
>
>
> Website: http://www.databaseadvisors.com
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
>
>
> Website: http://www.databaseadvisors.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