Hello
I have a form that contains a tab control. On each tab is a subform whose recordsource is a query. When combo boxes on the main form are updated the query is updated and the subform updates.
The problem that I have is that it takes a long time to refresh the subform and I'm sure there must be a better way to do it.
The following is an extract of the relevant code that I have at the moment:
The main form is called 'WorkOutstandingViewMainFormBeta'
The subform is called 'WorkOutstandingViewTab1Form'
When the form is first opened...
When a combo box on the main form is updated...
The slow part is Me.WorkOutstandingViewTab1Form.Form.RecordSource = "WorkOutstandingQuery". Instead of this I've tried the following:
But none of these work (no errors, it just doesn't update).
Other points that may be relevant:
- The 'Link Child Fields' and 'Link Parent Fields' properties of the subform are left blank
- The recordsource of the subform is left blank and is only set to the query when the main form is opened. When it is closed the recordsource is set to "".
Any thoughts or suggestions would be welcomed
Thanks in advance
Speedball
I have a form that contains a tab control. On each tab is a subform whose recordsource is a query. When combo boxes on the main form are updated the query is updated and the subform updates.
The problem that I have is that it takes a long time to refresh the subform and I'm sure there must be a better way to do it.
The following is an extract of the relevant code that I have at the moment:
The main form is called 'WorkOutstandingViewMainFormBeta'
The subform is called 'WorkOutstandingViewTab1Form'
When the form is first opened...
Code:
Me.WorkOutstandingViewTab1Form.Form.RecordSource = "WorkOutstandingQuery"
When a combo box on the main form is updated...
Code:
Dim strSQL As String
Dim strEditMode As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = Application.CurrentDb
Set qdf = db.QueryDefs("WorkOutstandingQuery")
strSQL = _
"SELECT " & _
"[UsedDueDate]-Date() AS DaysLeft, " & _
"* " & _
"FROM WorkOutstanding " & _
"WHERE " & ClientNameSelected & " " & _
"AND " & DirectorsNameSelected & " " & _
"AND " & TaskDateSelected & " " & _
"ORDER BY " & Ordering & ";"
qdf.SQL = strSQL
Me.WorkOutstandingViewTab1Form.Form.RecordSource = "WorkOutstandingQuery"
The slow part is Me.WorkOutstandingViewTab1Form.Form.RecordSource = "WorkOutstandingQuery". Instead of this I've tried the following:
Code:
DoCmd.Requery
Me.Refresh
Me.Requery
Me.WorkOutstandingViewTab1Form.Form.Refresh
Me.WorkOutstandingViewTab1Form.Form.Requery
Me.WorkOutstandingViewTab1Form.Form.Repaint
Me.WorkOutstandingViewTab1Form.Form.Recalc
Forms![WorkOutstandingViewMainFormBeta]![WorkOutstandingViewTab1Form].Refresh
But none of these work (no errors, it just doesn't update).
Other points that may be relevant:
- The 'Link Child Fields' and 'Link Parent Fields' properties of the subform are left blank
- The recordsource of the subform is left blank and is only set to the query when the main form is opened. When it is closed the recordsource is set to "".
Any thoughts or suggestions would be welcomed
Thanks in advance
Speedball