Results 1 to 3 of 3
  1. #1
    Dom is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2011
    Posts
    4

    Change controls on an empty form


    I have a split form with various options on it. I want those options to change if the form has no records to display. So, if there are records, there will be one set of options, and if there are no records, there will be another set. Any advice greatly appreciated! Thanks.
    Last edited by Dom; 01-18-2011 at 02:45 PM. Reason: Forgot to mention that the form is a split form

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    forms don't have a "nodata" event, do they? I just looked....I don't think they do. Basically, you need to check the recordcount of the form's dataset and issue .visible properties to the controls of choice based on the result of 0 or >0.

    what comes to mind to check this on the "open" event is:

    Code:
    on error resume next
    
    dim rs as dao.recordset
    set rs = me.recordsetclone
    
    rs.movelast
    rs.movefirst
    
    if rs.recordcount = 0 then
        'do something
    else
       'oops! records exist.  keep it the way it is!
    end if
    
    rs.close
    
    set rs = nothing

  3. #3
    Dom is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2011
    Posts
    4
    Thanks! I tried something similar but it didn't work, so I'll try yours!

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

Similar Threads

  1. form controls & recordset
    By slow&steady in forum Forms
    Replies: 2
    Last Post: 06-25-2010, 02:49 PM
  2. Populate or Empty Form
    By gazzieh in forum Forms
    Replies: 0
    Last Post: 12-02-2009, 05:56 AM
  3. Controls go blank on empty query result
    By kevdfisch in forum Programming
    Replies: 4
    Last Post: 08-25-2009, 08:07 AM
  4. Accessing form controls
    By dante in forum Forms
    Replies: 15
    Last Post: 07-28-2009, 08:26 AM
  5. Adding Controls to a Form
    By msmayhew in forum Programming
    Replies: 7
    Last Post: 12-14-2005, 03:26 PM

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