Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    May 2003
    Location
    Pennsylvania, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't open recordset (Access2K)

    I have a form containing a subform, and I want to edit the data in the underlying tables for both forms. (The database is split, and the table on which the subform is based is in the backend.) In the form's OnCurrent property, I have the following code:

    -------------------------------------------------------------

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rs1 As DAO.Recordset

    Set db = CurrentDb
    Set rs = db.OpenRecordset("MainForm", dbOpenTable)
    Set rs1 = db.OpenRecordset("Subform", dbOpenTable)

    -----------------------------------------------------

    When I open the form or move to a new record, I get Error 3219, "Invalid Operation" at the Set rs1 statement, which is not a very helpful error message.

    What does Error 3219 mean, and how can I fix this problem? (Is there a list of these error numbers in the help somewhere?)

    Thanks for the help.

    Don.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Can't open recordset (Access2K)

    The first argument to OpenRecordset can be:
    <UL><LI>The name of a table
    <LI>The name of a query
    <LI>A SQL SELECT statement[/list]You can't pass the name of a form to it, instead, you must pass the name of the table (or query) it is based on. Alternatively, you can use the RecordsetClone property of a form:

    Set rs = Me.RecordsetClone
    Set rs1 = Me.Subform.Form.RecordsetClone

  3. #3
    Star Lounger
    Join Date
    May 2003
    Location
    Pennsylvania, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't open recordset (Access2K)

    Hans:

    I did have table names in my OpenRecordset statement (I should have said "MainFormTableName" and "SubFormTableName" in my original question) when I got the 3219 error.

    When I try the RecordsetClone method that you suggested, I get Compile Error "Method or data member not found" for rs1.

    (When you said "Me.Subform.Form.RecordsetClone", did you mean to enter the statement just like that, or did you mean that I should enter the Subform and Form names there? Either way, I can't get it to work!)

    Regards,

    Don.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Can't open recordset (Access2K)

    In "Me.Subform.Form.RecordsetClone" you should replace Subform by the name of the subform as a control on the main form. You will see this name in the controls dropdown box in the toolbar and in the title bar of the properties window if you open the main form in design view and click once on the subform in it.

    By the way, you're using DAO - have you set a reference to the Microsoft DAO 3.6 Object Library in Tools | References...?

  5. #5
    Star Lounger
    Join Date
    May 2003
    Location
    Pennsylvania, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can't open recordset (Access2K)

    Hans:

    Thanks much. That fixed it.

    BTW, I did have the reference to the DAO library set.

    Regards,

    Don.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •