Run-time Error '7951' (1 Viewer)

G

gabrielho

Guest
Please Help,
The Error Message is :"'Run-time Error '7951':' 'You entered an expression that has an invalid reference to the RecordsetClone property.'

I DON"T KNOW WHY





Private Sub Combo2_AfterUpdate()



Dim rst As Recordset
'Dim rst As Recordset
Dim strCriteria As String



Set rst = Me.RecordsetClone
strCriteria = " NAME_PTYCODE = " & Me!Combo2
rst.FindFirst strCriteria
Me.Bookmark = rst.Bookmark

rst.Close
Set rst = Nothing

End Sub
 

RuralGuy

AWF VIP
Local time
Today, 03:04
Joined
Jul 2, 2005
Messages
13,826
Disambiguate your dim statement:
Dim rst As DAO.Recordset
 

hondauser

New member
Local time
Today, 02:04
Joined
Jun 25, 2013
Messages
5
I have encountered the same error message with the following codes. Any suggestions are welcome.

Private Sub cmdAddPO_Click()
Dim strSQL As String
Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim bintrans As Boolean

On Error GoTo cmdSave_Click_Error

If Me.cboPO = "" Then
MsgBox "PO is required"
End If
If Me.cboVendorName = "" Then
MsgBox "Vendor Name is required"
End If

Set ws = DBEngine(0)
ws.BeginTrans
bintrans = True
Set db = ws(0)

strSQL = "INSERT INTO [tblPOs] (PO, VendorName, EffectiveDate, EndDate)"
strSQL = strSQL & "VALUES ('" & Trim(Me.cboPO) & "', '" & Trim(Me.cboVendorName) & "', '" & Trim(Me.cboEffectiveDate) & "', '" & Trim(Me.cboEndDate) & "')"
CurrentDb.Execute strSQL


With Form_frmAddPO
.RecordsetClone.Requery
.RecordsetClone.findfirst "[tblPOs] = " & Chr(34)
.Bookmark = .RecordsetClone.Bookmark
End With


ws.CommitTrans
bintrans = False
DoCmd.Close

On Error GoTo 0
Exit Sub

cmdSave_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdSave_Click of VBA Document Form_frmAddPO"

End Sub
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 20:04
Joined
Jan 20, 2009
Messages
12,849
A clone is simply a pointer to the original recordset. You can move about in it independently but you can't requery it.

BTW. Best start a new thread for your questions especially when the original one is marked as solved.
 

Users who are viewing this thread

Top Bottom