Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    Make listbox selection a requirement

    Ive tried a few ways/looked at a lot of examples. I cant get this working. If the user has not selected a line in the listbox i want a message to come up and the code to exit.



    This is my poor attempt:

    Code:
    If Me.lstFileList = Null Then
    MsgBox "pick a template."
    Exit Sub
    
    Else: End If
    Ive tried using .value -1 and multiple other sugestions but it seems to totally skip past this and error on the later code.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    There are at least three errors in that code.
    The following should be ok

    Code:
    If Nz(Me.lstFileList,"") = "" Then
         MsgBox "pick a template."
         Exit Sub
    End If
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    brilliant, works perfect.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You're welcome
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Get file name from listbox selection.
    By Homegrownandy in forum Programming
    Replies: 4
    Last Post: 08-01-2018, 05:55 AM
  2. Replies: 10
    Last Post: 06-18-2013, 02:00 PM
  3. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  4. Make requirement in form
    By jmk909er in forum Programming
    Replies: 6
    Last Post: 10-22-2010, 01:05 PM
  5. Cancel listbox selection
    By vba-dev in forum Access
    Replies: 0
    Last Post: 10-26-2009, 12:18 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