How do you select the current record.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform that has a label (I use it as a button or link) with a click
event. Once you click the label a report is opened. The problem is that I
can't figure out how to get the record that I am clicking on the get the
focus. When the report opens now it shows the data from what ever record was
already selected, and I don't want the user to have to select the record and
then click the link.

Any ideas on how to go to the record where I click the label?
 
This is a very common question. You can search the newsgroups and read
previous posts before you add a new thread. Here is an example from a
similar request...

--
Rick B



Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.



See also: http://allenbrowne.com/casu-15.html
 
Back
Top