
Originally Posted by
ranman256
The subform should populate automatically IF you have the sub form bound by the query and the linking values to the master form,
Is this true?
if so, you could try the ON CURRENT event in the master form to refresh the sub form.
That's the problem. I don't know how to bind it to a query that has to be generated through vba (because an element of the query is a variable obtained from another form).
Also, there is nothing to link the subforms and the form that they load in. The primary form loads all overarching project data from the project table. The subforms load all data concerning that project using conjunction tables. The project ID that is the PK in project table is used to generate the PK for the junction tables but there are no direct relations otherwise.
The record sources on all reports are generated by VBA on load event.
For the main report:
Code:
Private Sub Report_Load()
Dim WorkOrder As String
WorkOrder = Forms!Project.WorkOrderCombo
Me.RecordSource = "SELECT * FROM Project Where [WorkOrder] = '" & WorkOrder & "';"
Me.WorkOrder = WorkOrder
Me.TCostEst = Forms!Project.TCostEst
Me.StopDate = Forms!Project.StopDate
Report.Requery
End Sub
For the sub reports:
Code:
Private Sub Report_Load()
Dim WorkOrder As String
WorkOrder = Forms!Project.WorkOrderCombo.Column(0)
SQL = "SELECT * FROM MatJoin WHERE [ID] LIKE '" & WorkOrder & "*';"
Me.RecordSource = SQL
End Sub