Run time error 7951 (1 Viewer)

anovice

New member
Local time
Today, 11:33
Joined
Jan 22, 2010
Messages
2
I've designed a simple form. There’s a list box displaying 2 columns from a db. When I select a row, it should copy the values to a different form.

Here’s the code for afterupdate of the listbox :

Dim rs as DAO.recordset

Set rs=me.recordsetclone

This is giving me the following error

Run time error ‘7951’
‘You entered an expression that has an invalid reference to the RecordSetClone property’

Any ideas why?? (I’m using Access 2003)
 

wazz

Super Moderator
Local time
Today, 19:33
Joined
Jun 29, 2004
Messages
1,711
Me refers to the form, not a control on the form. try:

me.lstBox.rowsource

but if the rowsource is a query, that will only get you the name of the query. then you'll have to get the rs from the query.
 

anovice

New member
Local time
Today, 11:33
Joined
Jan 22, 2010
Messages
2
This isnt working. Pls help me..all I want to do is select a row from a list box and display the details for that row in another tab!!!!!!!! Seem to be going nowhere with this..
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 11:33
Joined
Sep 12, 2006
Messages
15,614
the selected row is just

listboxname

if you want a different column its listboxname.column(x)

note that the first column is column(0) so

listboxname is (normally) the same as
listboxname.column(0)
 

wazz

Super Moderator
Local time
Today, 19:33
Joined
Jun 29, 2004
Messages
1,711
...all I want to do is select a row from a list box and display the details for that row in another tab...
you also have to use the correct terminology. what you're saying now is completely different than your first post.
 

hondauser

New member
Local time
Today, 04:33
Joined
Jun 25, 2013
Messages
5
Need assistance on resolving this 7951 error message.
When I run thru debug, it failed on .RecordsetClone.Requery statement. Could someone help me?

Here are my codes:
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
Me!lblMessage.Caption = "PO number is required"
Exit Sub
End If
If Me.cboVendorName = "" Then
Me!lblMessage.Caption = "Vendor is required"
Exit Sub
End If

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

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

strSQL = "INSERT INTO [tblPOs] (PO, VendorName, VendorId, EffectiveDate, EndDate)"
strSQL = strSQL & "VALUES ('" & Trim(Me.cboPO) & "', '" & Trim(Me.cboVendorName.Column(0)) & "', '" & Trim(Me.cboVendorName.Column(1)) & "', '" & 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
 

Users who are viewing this thread

Top Bottom