Hi
I have spent literally weeks trying to circumvent the 'blank' form issue when forms/subforms have zero records. How on earth is this supposed to work??
When I add a filter to a form and the form returns 0 records, I set allowadditions=true on my mainform; this prevents subsequent vba references to the subform (and/or its controls) from failing.
I store a given user' s filter/orderby settings in a table and when next opening the form, my form-open event applies the latest filters and orderby params. However, now when there 0 records returned and, again, I set allowadditions=true on my mainform, subsequent references to the subform do fail? (I think this is because the subform has not been opened?). This only happens when there is also a particular type of OrderBy specified i.e. if the user has elected to sort on a combobox control which is populated by a rowsource = "SELECT blah blah" statement. When these are added to the OrderBy an entry similar to that shown below appears in the form's OrderBy property:-
Code:
[Lookup_Parent__Table__Unique__No__Combobox].[Category] DESC
These orderBys work quite happily when records are returned.
This is how the combo is populated:-
Code:
SELECT TBL1.Friendly_Name As Category,
TBL1.Date_Record_Added,
TBL1.Added_By_Unique_No,
TBL1.Date_Record_Last_Updated,
TBL1.Last_Updated_By_Unique_No
FROM Table_Names AS TBL1 WHERE (TBL1.Deleted=False)
ORDER BY TBL1.Added_By_Unique_No
It seems to me that the only way to get around this is to force the subform open again whenever a 0 records condition is found... perhaps with some 'dummy' data? but how would I do that?? I certainly don't want any 'dummy' records displayed in the subform.
How would you the experts handle this please?