How to have a message box when option selected in userform already exists in database ?

  • Hello there !!!


    I am writting because I am having issues with identifying how to have a message box pop up whe the user selects an option in the userform that is already in the database. I have a userform for a tutor center that needs to identify based on the values entered on 4 TextBoxes if that test the student has already completed.


    What I need is a message box to pop up when the teacher selects an option that the student already has passed. The values to search are ComboBox2 (student name), ComboBox7 (module name), ComboBox9 (belt), and ComboBox8 (level), which can be found in the database in Column L (Helper Column) and verify if in Column M the status is Pass. This is the code I have at the moment, but it does not pop up with the message.



    Can someone help me out with this. I believe its simple, but not understand why is not working.

  • Hello and Welcome to the Forum:)


    You question does deserve a couple of comments ....


    Is your concatenated variable duplStr ... actually already stored in your database ...?


    Whenever you are searching for a string, more efficient than a loop ... would be using either Find or Match ...


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Thank you for your message !!!


    I actually figured out why it was not woking, and it was due to having a 1 instead of the i in the search.


    What I had:

    Code
    1. For i = 2 To LastRow
    2. If ws.Cells(i, 12).Value = duplStr And ws.Cells(1, 13).Value = "Pass" Then
    3. MsgBox "Student already completed and passed this level."

    How it worked:

    Code
    1.     For i = 2 To LastRow
    2. If ws.Cells(i, 12).Value = duplStr And ws.Cells(i, 13).Value = "Pass" Then
    3. MsgBox "Student already completed and passed this level."

    Hope this can help someone else that might be having this issue.

  • Glad you could get your code to work :)


    Make sure for your future messages, to use Code Tags when posting a macro ;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)