Results 1 to 2 of 2
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    Any ideas why this wont close the form if the listbox is empty?


    Hi,
    As the title suggests Im trying to close a form using VBA if a listbox is empty as per
    Code:
    Private Sub CloseApprovalForm_Click()
    If TimeApproval_lstbox.ListCount = 0 Then
    DoCmd.Close acForm, "frm_TimesheetApproval", acSaveNo
    End If
    End Sub
    It works if I comment out the If listcount bit, but I only want users to close it if its empty. Is it me being simple?

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    What is the Column Heads property. If it's Yes, you probably need to test for 1.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 11
    Last Post: 01-26-2012, 01:22 PM
  2. CALENDAR on form wont connect to TABLE
    By taimysho0 in forum Programming
    Replies: 6
    Last Post: 01-13-2012, 10:23 PM
  3. Replies: 4
    Last Post: 11-20-2011, 01:08 PM
  4. Replies: 2
    Last Post: 06-20-2011, 03:10 PM
  5. Form wont add data from a combo box
    By bopsgtir in forum Forms
    Replies: 9
    Last Post: 01-02-2011, 07:26 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