Another Vba problem

I have created an Access db with a front-end consisting of a number of forms.

One form 'frmRecordDetail' shows a complete record with its 12 fields. Another form 'frmRecordList' contains a subform 'subfrmList' which displays as a datasheet 4 fields from each record. The user is able to sort ascending/descending on any of the 4 fields. What I would like to happen is when a user double clicks on a particular record the form 'frmRecordList' closes and the form 'frm RecordDetail' opens displaying the record that was selected from the datasheet.

I thought the following code would work but all I get is Invalid Outside Procedure error

The code is placed in the dbclick form event for the subform and goes like this.....

Private Sub Form_DblClick(Cancel As Integer)

stFrmName = "FrmDisplayRecord"
stLinkCriteria = "[RefNo]=" & "'" & Me![RefNo] & "'"

DoCmd.Close acForm, "FrmRecordList"

DoCmd.OpenForm stFrmName, , , stLinkCriteria

End Sub


Hope someone can help.....