Results 1 to 4 of 4
  1. #1
    Gray is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    England
    Posts
    16

    Blank Form Issue

    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?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi Gray

    I'm not sure that I understand the problem corectly, but if you are saying that applying filters and orderby causes problems you could test for the existance of records in the form's OnOpen event and if there are no records then set the FiltersOn to False and OrderBy to "".
    Remember that a subform opens before the main form opens.

    Hope this helps.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    As you know, fundamentally, if there is no record in the record source & no ability to add a new record - - then the form opens blank.

    Nothing changes that - so - one either adds a label saying "No Data for this Record" or whatever that toggles on/off visibility... or a single dummy record...or permit new data entry... that's really your universe of choice.

    Your order by issue is somewhat tangental to your fundamental issue. The correct answer depends on your situation. I myself have used the label visibility technique - but also sometimes it is only a matter of education of the users.....

    Hope this helps.

  4. #4
    Gray is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    England
    Posts
    16
    Hi All

    Thanks for the replies.... As you say, I can check for the existence of a '[Lookup' in the orderby before applying the filter and switch OrderByOn=False before the filter to nip the problem in the bud... but I am still curious as to why it's these particular sort criteria i.e. '[Lookup_ xxxx ]' that cause issues... I imagine thousands of people use thse in orderbys so I am surprised to find it occurs?

    rgds

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to open a blank form?
    By WhatnThe in forum Access
    Replies: 15
    Last Post: 08-05-2011, 02:41 PM
  2. I want my form to open blank
    By uneek78 in forum Forms
    Replies: 10
    Last Post: 01-12-2011, 01:01 PM
  3. Opening a form at a blank record
    By Remster in forum Forms
    Replies: 2
    Last Post: 09-14-2010, 07:46 AM
  4. Replies: 1
    Last Post: 06-25-2010, 09:56 AM
  5. blank on entry on add a record form
    By gmee in forum Forms
    Replies: 1
    Last Post: 10-07-2009, 07:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums