Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Chante subform recordsource from Unbound Main form

I have form that users will enter their tasks for each day.  For the txtDate control, in the after update event, I need to have two sub-forms have their recordsource change to present all records that are associated with the TimeSheetID for that date.  However, I can't seem to get the recordsource change to work.  I need to separate the select statemetns also based on by time of task, VAR and CON.


Sandra

Private Sub CompletedTasks( lngTSID As Long)
Dim strSelectVAR As String
Dim strSelectCON As String

strSelectVAR = "SELECT CompletedID, TaskID, TaskTime, TimeCode, EndTime, Description, TSID, StopWatch " & _
    "FROM TblCompletedTask " & _
    "WHERE TblCompletedTask.TaskID Like '*VAR*' AND TblCompletedTask.TSID = " & lngTSID & " "
   
strSelectCON = "SELECT CompletedID, TaskID, TaskTime, TimeCode, EndTime, Description, TSID, StopWatch " & _
    "FROM TblCompletedTask " & _
    "WHERE TblCompletedTask.TaskID Like '*CON*' AND TblCompletedTask.TSID = " & lngTSID & " "


Me.sfrmCompletedTaskVAR.RecordSource = strSelectVAR
Me.sfrmCompletedTaskCON.RecordSource = strSelectCON

Me.Form.sfrmCompletedTaskVAR.Refresh
Me.Form.sfrmCompletedTaskCON.Refresh

Me.Refresh

End Sub
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan 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
And the refreshes should be requeries, but changing the recordsource should requery the subforms automatically - making those lines unneeded (so try removing them).

Finally - if you haven't already, set some breakpoints in the code and verify that the correct TSID is indeed being passed to that procedure.
Avatar of Sandra Smith

ASKER

Yes, when I was using FORM, I had it originally in the wrong place, thank you.

Sandra