+ Reply to Thread
Results 1 to 4 of 4

Problem in combobox and textbox

Hybrid View

  1. #1
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Problem in combobox and textbox

    Hi,

    I need to enter a project name in the textbox (Name: txtProjectName) and the entered project name will be automatically stored in the combo box (Named: ProjectNames). No problem in the above steps. The problem is here, it need to show the error if I enter the project name which is previously exist. The below code doesn't work for me


    
    Private Sub cmdOK_Click()
    For i = 0 To ProjectNames.ListCount - 1
        If ProjectNames.List(i).value = txtProjectName.Value Then
            MsgBox "This Project is already exists!", vbInformation
            Exit For
        End If
    Next I
    
    End Sub
    It shows error for each project I enter in the textbox even though the project name doesn't exist already.

    Please help.
    Last edited by abduljaleel.mca; 04-15-2013 at 10:40 AM.

  2. #2
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Re: Problem in combobox and textbox

    Hi,

    No response yet for the above thread, Please let me know if anybody can help me out on this.

  3. #3
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Problem in combobox and textbox

    In your For/Next loop, you have two different variables called out...."i" in the For statement, and "I" in the Next statement
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

  4. #4
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Re: Problem in combobox and textbox

    Thanks for the reply John, but it was not the error.
    I did it in different way and got the answer. Just stored all the values from combo box to another sheet and used the below formula.

    For ki = 4 To LastRow
    If Cells(ki, 2).Value = txtProjectName.Value Then
       MsgBox "This Project is already exists!", vbInformation
       GoTo EndMacro
    End If
    Next ki

+ 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