RecordsetClone for ADP? SEE Code

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi Josh,
I am using the following code for this, don't know
if it's the best way but it works for me:


Sub MoveToContact(f As Form, ContactID As Integer)

'move to the specified contact record

Dim rst As Recordset
Set rst = f.RecordsetClone

rst.Find "ContactID = " & ContactID

If rst.EOF = True Then
'record not found
MsgBox ("Record not found.")
Else
'Synchronize the recordset and the form
f.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

Regards
Chris
 
Thanks Chris, the whole rst.Find was the key where DAO uses rst.FindFirst

Had a hard time finding any documation on this. Thanks for your help


Chris said:
Hi Josh,
I am using the following code for this, don't know
if it's the best way but it works for me:


Sub MoveToContact(f As Form, ContactID As Integer)

'move to the specified contact record

Dim rst As Recordset
Set rst = f.RecordsetClone

rst.Find "ContactID = " & ContactID

If rst.EOF = True Then
'record not found
MsgBox ("Record not found.")
Else
'Synchronize the recordset and the form
f.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

Regards
Chris
-----Original Message-----
I am having a problem trying to pass a result back to the main form without
filtering all of the records.

History: I have a search form (frmSearch) that searches through records
(ADO) that displays those results into a Datasheet (frmResults). I have an
OnClick event that is supposed to load that record into the Main form
(frmMain).
easy enough NOT! :)

Problem: I can pass by filtering, but don't want to do that because there
are over a thousand records and it just sucks. when i try to do a
RecordsetClone / Bookmark it fails and I get a 438 Error "Object doesn't
support this property or method".

Question: is there a way to do this using ADO/ADP?

See code for example:

Private Sub txtJulianID_DblClick(Cancel As Integer)

On Error GoTo dblclick:
' Set RecordSetClone'
Dim oClone As Object
Set oClone = Forms!frmMain.RecordsetClone

oClone.FindFirst "[JulianDate]= " & Me![JulianDate]
Forms!frmMain.Bookmark = oClone.Bookmark
' Open the Main form
DoCmd.OpenForm "frmMain", acNormal

' Dim stDocName As String
' Dim stLinkCriteria As String
'
' stDocName = "frmMain"
'
' stLinkCriteria = "[JulianDate]= " & Me![JulianDate]
' DoCmd.OpenForm stDocName, , , stLinkCriteria

dblclick_exit:
' Close Form
DoCmd.Close acForm, "frmResults"

Exit Sub
dblclick:
MsgBox "Error - " & err.Number & vbCrLf & err.Description,
vbCritical, " Error on Double Click"
Resume dblclick_exit
End Sub


.
 
Back
Top