Open Form on Current Record

  • Thread starter Nikki Norris via AccessMonster.com
  • 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
 
D

Dirk Goldgar

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top