Open Form on Current Record

  • Thread starter Thread starter Nikki Norris via AccessMonster.com
  • Start date Start date
N

Nikki Norris via AccessMonster.com

I have a main form with a subform on it. When I double click on a row in
the subform (datasheet) I want open another form which will bring up detail
records for the current record. My code is not working. Here is my code:

Private Sub Form_DblClick(Cancel As Integer)
If Not Me.NewRecord Then
DoCmd.OpenForm "frmEdit2", WhereCondition:="SSN=" & SSN
End If
End Sub

Does anyone know what I'm doing wrong?

Thanks,
Nikki
 
"Nikki Norris via AccessMonster.com" <[email protected]>
wrote in message
I have a main form with a subform on it. When I double click on a
row in the subform (datasheet) I want open another form which will
bring up detail records for the current record. My code is not
working. Here is my code:

Private Sub Form_DblClick(Cancel As Integer)
If Not Me.NewRecord Then
DoCmd.OpenForm "frmEdit2", WhereCondition:="SSN=" & SSN
End If
End Sub

Does anyone know what I'm doing wrong?

You don't say exactly how it's "not working", but I can guess at two
possibilities:

1. Usually social security numbers, which I guess SSN is, are stored as
text. If that's the case here, you need quotes around the value in the
WhereCondition:

DoCmd.OpenForm "frmEdit2", _
WhereCondition:="SSN='" & SSN & "'"

2. The form's DblClick event is only going to fire when you click on the
record selector. If you are clicking on the cells of the datasheet, the
event won't fire. You may (or may not) want to make this code into a
common function and call it from the OnDblClick event property of all
controls on the form, as well (maybe) as that of the form itself.
 
Back
Top