Link to home
Start Free TrialLog in
Avatar of jpleaner
jpleaner

asked on

Changing RecordSource of Subform at runtime

Experts,

I am trying to change the recordsource of a subform at run time.   In short, I have a main form with a subform.  The main form and subform are linked so that as you scroll through the records on the subform datasheet, the main form brings up the details for the client in the subform.

Before the main form opens (loads) i want to change the record source of the subform. This is what i have at the moment:

strSQL = "SELECT tbl_calls.days_away, tbl_calls.code, tbl_calls.best_time, tbl_calls.user, tbl_client.client " & _
             "FROM tbl_calls INNER JOIN tbl_client ON tbl_calls.code = tbl_client.code " & _
             "WHERE (((tbl_client.client) = 'PROSPECT')) " & _
             "ORDER BY tbl_calls.days_away DESC;"
     
Forms!frm_ReorderCallList.RecordSource = strSQL
   
stLinkCriteria = "Call List"
stDocName = "frm_clients"

DoCmd.OpenForm stDocName

In  this case "frm_ReorderCallList" is the subform and "frm_clients" is the main form.   Problem is that when it executes i get an error telling me i cant change the recordsource because "frm_ReorderCallList" is not open?

Thanks

Jason
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial