Duane suggested that you could OpenRecordset() on whatever is the
RecordSource of the report, e.g.:
Dim rs As DAO.Recordset
Set rs = Currentdb.OpenRecordset(Me.RecordSource)
You now have a recordset that has the same records as the report, so you
can now FindFirst the one you want, and get at that information.
Your reply indicates that you want one specific record rather than the
whole set. It would be better to just get that one record:
Dim strSql As String
strSql = "SELECT * FROM MyTable WHERE RegistryID = " & lngSendID & ";"
Set rs = dbEngine(0)(0).OpenRecordset(strSql)
With rs
If .RecordCount > 0 Then
strFname = Nz(!FirstName, vbNullString)
strLname = Nz(!LastName, vbNullString)
'etc
End If
End With
rs.Close
Set rs = Nothing
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Bill said:
You lost me on that one Duane. Can you give me a quick
code example and what the syntax would be to access
a field?
What I had tried when I encountered the RecordsetClone
method error is: (Just to be clear about what I'm trying to
accomplish)
Me.RecordsetClone.FindFirst "[RegistryID] = " & lngSendID
With Me.RecordsetClone
strFname = ![FIRSTNAME]
strLname = ![LASTNAME]
strAdr = ![ADDRESS]
strCS = ![CITYSTATE]
strZip = ![ZIP]
strHomeNo = ![HOMEPHONE]
strWorkNo = ![WORKPHONE]
strCellNo = ![CELLPHONE]
End With
Duane Hookom said:
Can you create a recordset based on the Record Source property of the
report? You might need to add the Filter property if the filter is on.
--
Duane Hookom
MS Access MVP
Oh-Oh!!! First time I've ever had an occasion to
want the use of the RecordsetClone in a report
and discover that method isn't valid for reports.
Yikes! In the OnOpen code, I need to search
for a specific ID in the report's underlying
RecordSource to extract some information
that is constant on each page of the report.