+ Reply to Thread
Results 1 to 3 of 3

Listbox data required

  1. #1
    Registered User
    Join Date
    05-23-2006
    Posts
    2

    Listbox data required

    I am pretty new to this forum and have had most of my questions answered by searching other threads. But can't find an answer on this one.

    I have created a form for data entry and it has several list and text boxes. I have used an if then statement to validate that the text boxes have data in them at the time of execution. I would like to do the same with the list box but the code does not work. The list box is poplulated but no data is selected. When I press "OK" I would like for it to validate that data is selected / highlighted.

    Private Sub cmdOK_Click()
    If lboTeam.value = "" Then
    MsgBox "You need to fill in your Team Name"
    Exit Sub
    End If

    If txtPlayer.Value = "" Then
    MsgBox "You need to fill in the Player's Name"
    Exit Sub
    End If

    Any help would be greatly appreciated. Thanks.

  2. #2
    Tom Ogilvy
    Guest

    RE: Listbox data required

    Private Sub cmdOK_Click()
    If lboTeam.ListIndex = -1 Then
    MsgBox "You need to Select your Team Name"
    Exit Sub
    End If

    --
    Regards,
    Tom Ogilvy


    "kuzniaj" wrote:

    >
    > I am pretty new to this forum and have had most of my questions answered
    > by searching other threads. But can't find an answer on this one.
    >
    > I have created a form for data entry and it has several list and text
    > boxes. I have used an if then statement to validate that the text
    > boxes have data in them at the time of execution. I would like to do
    > the same with the list box but the code does not work. The list box is
    > poplulated but no data is selected. When I press "OK" I would like for
    > it to validate that data is selected / highlighted.
    >
    > Private Sub cmdOK_Click()
    > If lboTeam.value = "" Then
    > MsgBox "You need to fill in your Team Name"
    > Exit Sub
    > End If
    >
    > If txtPlayer.Value = "" Then
    > MsgBox "You need to fill in the Player's Name"
    > Exit Sub
    > End If
    >
    > Any help would be greatly appreciated. Thanks.
    >
    >
    > --
    > kuzniaj
    > ------------------------------------------------------------------------
    > kuzniaj's Profile: http://www.excelforum.com/member.php...o&userid=34712
    > View this thread: http://www.excelforum.com/showthread...hreadid=544796
    >
    >


  3. #3
    Registered User
    Join Date
    05-23-2006
    Posts
    2
    Works great thankx for the quick response.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1