Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Angry Unanswered: Setting a subform's Source Object through code

    I know I've gotten this to work in the past, so there must be something really obvious that I'm missing. I have a subform that will display one of several queries. I want to allow the user to select from a list (combo box), click a button, and have the query in datasheet view displayed in the subform.

    This works fine if I define subform control's SourceObject in the properties window. But I get a run-time error when using code. The subform is named "chldQV". The master form is named "frmQueryViewer". The query name selected comes from the combo box, and it's the actual name of the query from the database objects window.

    Private Sub Button_Click()
    Dim vQryName as String

    vQryName= "'" & cboQueryList & "'"

    chldQV.SourceObject= vQryName

    End Sub

    The error returned is "The Microsoft Jet database engine could not find the object '~sq_cfrmQueryViewer~sq_cchldQV"

  2. #2
    Join Date
    Aug 2003
    Posts
    123
    Never mind. I realized since it was a query object, I needed to preface the object name with "Query.", so the code became:

    chldQV.SourceObject = "Query." & cboQueryList
    where cboQueryList = "LIST_OF_CLIENTS"

Posting Permissions

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