Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Setting sub-form's recordsource (2007)

    In a sub form's OnCurrent event I'm attempting to set the recordsource property of one of its sub-forms (3rd level deep) . The following code does not raise any errors and the query is successfully and correctly built, but the affected form does not display any data. If I comment out the OnCurrent code, the form does display the data as previously defined by the query. In my first attempt I did not have the form requery thinking the assignment to the recordsource would force a requery … neither approach overcomes my problem. I tried several searchs and didn't find anything on point.

    Set frm = Forms!frm_S_tblDisclosureText_Main!frm_S_tblDisclo sureText_Sub.Form!frm_S_tblDisclosureText_TokenMas ter.Form
    Set rst = Me!frm_S_tblDisclosureText_RptObj.Form.RecordsetCl one
    rst.FindFirst "[rptID]=" & glngProposal
    fProposal = Not (rst.NoMatch)
    stSQL = BuildSQL_qryDiscTextTokens_TokenIDUnused(fProposal )
    inErr = CreateQueryDEF("_qryDiscTextTokens_TokenIDUnused", stSQL)
    If inErr = False Then
    frm.RecordSource = "_qryDiscTextTokens_TokenIDUnused"
    frm.Requery
    Else
    MsgBox ..describes error
    End If

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

    Re: Setting sub-form's recordsource (2007)

    Have you checked whether the query _qryDiscTextTokens_TokenIDUnused returns any records?

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Setting sub-form's recordsource (2007)

    And I assume your CreateQueryDef function handles the situation in which the query already exists?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Setting sub-form's recordsource (2007)

    Hans & Mark,

    Thanks for the questions and I'm sorry I was clearer in my original post. The query is correctly built (and a delete is in the CreateQueryDEF function). When run from outside outside the forms the query returns a recordset which reflects the criteria that was defined during the last execution of the Build and Create function. And If I comment out the resetting of the sub-form recordsource in the code, this same recordset is displayed in the sub-form's sub-form.

    Marty

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

    Re: Setting sub-form's recordsource (2007)

    I'm afraid it's too difficult (at least for me) to know what goes wrong without seeing the database. Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  6. #6
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: Setting sub-form's recordsource (2007)

    I'll see if I can set up a stripped down version.

    Marty

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Setting sub-form's recordsource (2007)

    In looking at this again, I might try adding this one line before you set the recordsource:

    frm.recordsource = ""

    Can't do any harm, and might do some good.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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