David assume for our discussion that you have a form and it is set to
datasheet view and this form is based on the select query you mentioned
above. Also, the form with all the tabs on it is also based on this same
query. If I understand you correctly you want to doubleclick a record on
the first form so that it opens your tab form and only display the one
record that you double-clicked on the first form. If this is correct then
open the first form in design view select view/properties from the main
menu. Click the Event tab and scroll down to the On Dbl Click event and
click the ellipsis(...) to open the code window. Paste this appropriate
code shown below. Replace the names with the names of the controls/forms in
your app.
'Use this if the search field is a number field
Private Sub Form_DblClick(Cancel As Integer)
Dim intSearch As Long
intSearch = Me.MyIDField
DoCmd.OpenForm "MyTabForm", acNormal, , "[MyIDField] = " & intSearch
End Sub
'Use this if the search field is text field
Private Sub Form_DblClick(Cancel As Integer)
Dim strSearch As String
strSearch = Me.MyTextField
DoCmd.OpenForm "MyTabForm", acNormal, , "[MyTextField] = '" & strSearch
& "'"
End Sub
'Use this if the serach is a date field
Private Sub Form_DblClick(Cancel As Integer)
Dim dteSearch As Date
dteSearch = Me.MyDateField
DoCmd.OpenForm "MyTabForm", acNormal, , "[MyDateField] = #" & dteSearch
& "#"
End Sub
Now when you double-click a record(you must doubleclick the record selector
at the left of the record) on your first form it will open the tab form to
the record you just doubleclicked. Hope this helps.
--
Reggie
----------
David said:
Hi Reggie,
Thanks for the clarificcation
Do you know where I may find the actual code or code samples to implement
my requirement? Recall my requirement is to be able to open an arbitrary
RECORD in a QUERY from say, a command button on a FORM.