Results 1 to 5 of 5
  1. #1
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56

    RecordSource Property of a form


    I am trying to set the Record Source of a subform to a query like this:
    Me!Copysubform1.RecordSource = LSQL

    LSQL is the query string
    Copysubform1 is the subform

    I get the following error:
    Object doesn't support this property or method.

    Actually the subform1 is bound to a table.

    I have written this code in the OnChange event for a combobox on my main form. So when I change my selection in the combobox, the subform should display the record from the table if one exists, or else I should be able to fill the subform (which should be empty when the combobox selection value doesn't already exist in the table)

    FYI: I have tried many variants for setting the recordsource property I found on various sites, but no luck

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Does this work?

    Me.Copysubform1.Form.RecordSource = LSQL
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56
    Nope. Doesn't work.
    I get the error: "This expression is typed incorrectly, or is it too complex to be evaluated. For example, a numeric expression may contain too many complicated elements ......"

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well it likely worked and revealed the next problem. That sounds like a problem with the SQL. Try this to help debug it:

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You need to use the name of the main form control containing the subform, not the name of the subform itself. So if for example the name of the control is SubFormControl1, you wou have:

    Me.SubFormControl1.Form.RecordSource = LSQL

    What confuses a lot of people is the fact that the name of the subform is not used at all in this context.

    John

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 05-10-2012, 10:57 AM
  2. Update recordsource of one field on a form
    By TinaCa in forum Programming
    Replies: 1
    Last Post: 03-06-2012, 06:56 PM
  3. Replies: 8
    Last Post: 08-08-2011, 02:05 PM
  4. close form code not releasing recordsource..
    By dmeehanjr in forum Forms
    Replies: 1
    Last Post: 08-12-2010, 05:42 PM
  5. Changing A Report Recordsource from a form
    By warrenjburns in forum Reports
    Replies: 0
    Last Post: 04-09-2009, 05:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums