Set recordsource of a subform using code
Posted on 2011-05-03
I have a bunch of queries. Which one will be executed depends on the date range the user enters in a couple of textboxes on a form. How would I modify the code below to set a SUBFORM's recordsource? The code below was used on another one of my projects where I set the FORM's recordsource. This time, I need to set the SUBFORM's recordsource. The subform's name is SUBFORM1. Thank you.
QueryNameForReport = QueryName
If (IsNull(ANYDATA)) Then GoTo NoDataMessage
Set frm = Forms("Form1")
.RecordSource = QueryName <------ (QueryName is a variable that is set to the name of the
appropriate query based upon which date range a