I am using a tabbed form. I set criteria in one Tab, then open another Tab with a subform (record source is VBA module) that needs to refresh when the Tab has focus based on criteria set in the first Tab. When the Tab opens all fields say #delete# . If I use the Records menu, Refresh All, the records appear with the criteria set by a flag in another Tab. However, if I go back to the first Tab and change the criteria, go back to the subform Tab, the same results appear even after Refresh All.
I’m sure it’s something simple I’m missing, but how do I get the subform to refresh when the Tab has focus based on the current criteria?
Details:
Tab 1 – has a flag to set. Fields on form
Tab 2 – Product Selection Method, uses a subform based on a query with 2 buttons. Button 1 (Product Hierarchy) stores the query results in a temp table, closes Tab 2, Opens Tab 4. Button 2 (Product Vendor), closes Tab 2, Opens Tab 3.
Tab 3 – Vendor Selection Method, uses a subform based on a query with one button. The button stores the query results in a temp table, closes Tab 3, Opens Tab 4
Tab 4 – Product Selection, uses a subform based on a query built in VBA that uses the temp table created in either Tab 2 or 3 and applies the criteria based on flag set in Tab 1.
After hitting button in Tab 2 or 3, Tab 4 opens after running open code:
Public Sub HierClose_SkuAdd()
Me.AddSkuTab.Visible = True
Me.AddSkuTab.SetFocus
Me.HierarchyTab.Visible = False
End Sub
On the Main form, I tried adding Me.Refresh to Tab 4 On Click. In the subform I’ve tried to add Me.Refresh to a number of properties. I’ve put the Query module in On Current, On Load, On Focus, On Open. Still the same result. I’ve added a number of properties to the end of the code that generates the query for the subform to try refreshing. No luck.
Private Sub Form_Current()
Dim vSQL As String 'query string
Dim vExclude7 As String 'exclude7 value
vExclude7 = Forms("frmOfferCreate").Exclude7
vSQL = "SELECT *"
vSQL = vSQL & " FROM [tblActive Offer Listing-Temp]"
vSQL = vSQL & " WHERE [tblActive Offer Listing-
Temp].[Event#]=DLookUp(""[Event#]"",""tblTempEventRecord"")"
vSQL = vSQL & " AND [tblActive Offer Listing-Temp].[Offer Number]=DLookUp(""[Offer
Number]"",""tblTempOfferNumber"")"
If vExclude7 <> "0" Then 'If 0 ignore last And statement
vSQL = vSQL & " AND [tblActive Offer Listing-Temp].[CentEnding] <> ""97"""
End If
vSQL = vSQL & " ORDER BY [tblActive Offer Listing-Temp].[Sku]"
CurrentDb.QueryDefs("qryDept-Sub-Class Filter Select Activate").SQL = vSQL
'DoCmd.OpenForm "frmSku Select Activate"
'Me.Refresh
'Me.Active
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acRefresh, , acMenuVer70
End Sub