Maybe someone had such a problem...?
Maybe someone had such a problem...?
Maybe you should state what you're trying to do in simple terms rather than just show what's not working. I see so many possible issues there, mainly that you cannot set a form recordsource to something like "T12". It has to be either a valid sql statement or the name of a query or a variable that holds one of those. If it were a variable, you would not enclose it in quotes. So that's 2 issues. The message is saying it can't find a field named T12. That's another. A query is not a member of a form collection, so that's another. It's usually done along the lines of
If this Then
Me.Recordsource = "SELECT * FROM tbl1..."
Else
Me.Recordsource = "SELECT * FROM tbl2..."
End IF
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
I want to change from the MainForm RecordSource in query Q12....
Code on main form wants to change property of its subform, so like this:
[ml-sub] is name of control on main form holding the subform.
ml-sub is a bad name to use. Access could construe it to be expression ml minus sub. Better would be mlsub or ml_sub.Code:Private Sub BookType_AfterUpdate() If Me.[BookType] = "Table-1" Then Me![ml-sub].Form.RecordSource = "SELECT * FROM Q1" Else Me![ml-sub].Form.RecordSource = "SELECT * FROM Q2" End If End Sub
Last edited by davegri; 03-05-2021 at 12:58 PM. Reason: more
Code on main form wants to change property of its subform, so like this:
[ml-sub] is name of control on main form holding the subform.
ml-sub is a bad name to use. Access could construe it to be expression ml minus sub. Better would be mlsub or ml_sub.Code:Private Sub BookType_AfterUpdate() If Me.[BookType] = "Table-1" Then Me![ml-sub].Form.RecordSource = "SELECT * FROM Q1" Else Me![ml-sub].Form.RecordSource = "SELECT * FROM Q2" End If End Sub
Thank you very much...