[AccessD] Force a dblclick event on a form control

Darren - Active Billing darren at activebilling.com.au
Tue May 17 16:56:59 CDT 2011


Hi Darrell
Assume you have a text box called txtLastName on a form called frmEmployees.
Assume on that form is a routine that displays a message box on the double
click of that field.

Private Sub txtLastName_DblClick (Cancel As Integer)
MsgBox "Hi this is the Last Name text box from the employees form",
vbInformation, "Last Name DoubleClick"
End Sub

Ok - Cool - Assume you have a command button (called Command2) on the same
form and you want the double click of the LastName text box to 'fire' when
the button is clicked, do something like this...

Private Sub Command2_Click()
txtLastName_DblClick -1
End Sub
(the minus one bit above is to satisfy the "Cancel as integer" param on the
DoubleClick routine)

Now...if you want the double click routine on the Lastname field to be
'fired' from a button called 'Command1' on another form you could do this...
First change the status of the Private Sub routine on the LastName double
click into a Public Sub - like this...

Public Sub txtLastName_DblClick(Cancel As Integer) ''<--note it is public
sub now
MsgBox "Hi this is the Last Name text box", vbInformation, "Last Name
DoubleClick"
End Sub

Private Sub Command1_Click()''<---not this should be on a totally different
form
Forms("frmEmployeesform1").txtLastName_DblClick -1
End Sub

There probably are better ways of handling this and the gurus here will
suggest them. This has worked for me a zillion times.
Now, having said all that if the information in this control that is to be
double clicked is being 'fired' or called from another place you may want to
give somethought to moving the doubleclick code/logic into a more public
place, like in a module etc. 
Hope it makes sense - See ya
Darren

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darrell Burns
Sent: Wednesday, 18 May 2011 6:14 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Force a dblclick event on a form control

Anybody know how I could trigger a dbl-click event on a form control?
Thx,
-Darrell

-- 
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