Setting recordsource for subform

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Welch

    #1

    Setting recordsource for subform

    In a main form, I build an SQL string based on several unbound combo boxes
    and then I try to set this string to be the recordsource for a subform like
    this:

    Private Sub cmdfind_Click()
    Dim strSQL As String
    strSQL = [a valid SQL string]
    Me.child1.Form. RecordSource = strSQL
    End Sub

    I get error 2001: "You canceled the previous operation."
    The button cmdfind is in the main form's header, and the subform is open but
    with no recordsource when the button is first clicked.

    What's wrong?
    thanks in advance


  • John Welch

    #2
    Re: Setting recordsource for subform

    I figured it out: My sql was valid syntacically, but there was a type
    mismatch ( I said "WHERE field = '2', and it was a number field). Not sure
    why this error came up, but oh well.
    [color=blue]
    > In a main form, I build an SQL string based on several unbound combo boxes
    > and then I try to set this string to be the recordsource for a subform
    > like this:
    >
    > Private Sub cmdfind_Click()
    > Dim strSQL As String
    > strSQL = [a valid SQL string]
    > Me.child1.Form. RecordSource = strSQL
    > End Sub
    >
    > I get error 2001: "You canceled the previous operation."
    > The button cmdfind is in the main form's header, and the subform is open
    > but with no recordsource when the button is first clicked.
    >
    > What's wrong?
    > thanks in advance
    >[/color]


    Comment

    Working...