Double Click for a form

  • Thread starter Thread starter Charles Agin
  • Start date Start date
C

Charles Agin

How would I be able to use the double click event for a text box in a subform
to open a particular form to specific record?
 
In the DblClick event procedure, use OpenForm with a WhereCondition.

This kind of thing:

Private Sub ID_DblClick(Cancel As Integer)
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If IsNull(Me.ID) Then
MsgBox "No value to open."
Else
strWhere = "ID = " & Me.ID
DoCmd.OpenForm "Form2", WhereCondition:= strWhere
End If
End Sub

If the field you are linking on is a Text field (not a Number field), you
need extra quotes:
strWhere = "ID = """ & Me.ID & """"
Explanation of the quotes:
http://allenbrowne.com/casu-17.html
 
In the DblClick event procedure, use OpenForm with a WhereCondition.

This kind of thing:

Private Sub ID_DblClick(Cancel As Integer)
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If IsNull(Me.ID) Then
MsgBox "No value to open."
Else
strWhere = "ID = " & Me.ID
DoCmd.OpenForm "Form2", WhereCondition:= strWhere
End If
End Sub

If the field you are linking on is a Text field (not a Number field), you
need extra quotes:
strWhere = "ID = """ & Me.ID & """"
Explanation of the quotes:
http://allenbrowne.com/casu-17.html

Also, if you want the double-click to work on the record selector (the
arrow to the left of the record), you need to add the code to the
DblClick event of the Form itself.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
Back
Top