Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error 2455

Status
Not open for further replies.

sunmorgus

Programmer
Nov 9, 2004
81
US
Hello. I am trying to set the recordset of a form on open using an ado recordset, and I get Runtime Error 2455 - You entered an expression that has an invalid reference to the property Recordset. Below is the code I am using to get the recordset for the form (I have omitted my SQL statement, as it is very long and will take up alot of the page; if you need to see it, let me know and I will post it):

Code:
    Dim adRMAConn As ADODB.Connection
    Dim adRMARS As ADODB.Recordset
    Dim RMABaseSQL, srchRMA, srchSN As String

    Set adRMAConn = New ADODB.Connection
    adRMAConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Nick DeMayo;" & _
                    "Data Source=T:\Database Project\Customer Support Tables.mdb;" & _
                    "Mode=ReadWrite|Share Deny None;Persist Security Info=False;" & _
                    "Jet OLEDB:System database=t:\Database Project\Secured.mdw", "Nick DeMayo", "Nic"
        'build the where statement
    If Not (IsNull(Forms!frmRMAProcess!txtRMANumber)) Then
        srchRMA = RMABaseSQL & " WHERE ((([Work orders].[Closed Date]) Is Null) AND (([Work orders].[RMA Number])=" & Forms!frmRMAProcess!txtRMANumber & "));"
    End If

    Set adRMARS = New ADODB.Recordset
    adRMARS.CursorLocation = adUseClient
    adRMARS.Open srchRMA, adRMAConn, adOpenDynamic, adLockOptimistic
    Set Forms("RMA Base Form").Recordset = adRMARS

I do not get any errors on the SQL statement, and the "Set Forms("RMA Base Form").Recordset = adRMARS" is the highlighted line in the error. I have used this method before for other forms in my DB, but never for one this large. Also, this form has a couple of subforms on it, could they be the cause? Any help you can provide would be greatly appreciated! Thanks in advance!
 
Hi sunmorgus

Do you need to have "RMA Base Form" open before you can set its .Recordset?

So, add DoCmd.OpenForm "RMA Base Form" before you try and set the recordset.

Worth a try...

Mac
 
I am sorry, I guess I should have been clearer on that point. This code is in the open event of the RMA Base Form, so the form is open when the code runs. Should I move this code to the load event? Would that help?
 
Thanks PHV, I just so happened that I ran accross that article last night, and through a little bit of reading discovered that what I was trying to do would not work. I am using Access 2000 for my database, and 2K does not support binding of forms with ADO unless you are using SQL server and a query that only accesses one table, as explained in this article, linked too on the article you sent me. Thank you all for your help though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top