Results 1 to 7 of 7

Thread: [RESOLVED] Required field entry datat if combobox value is select?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Resolved [RESOLVED] Required field entry datat if combobox value is select?

    Hello all

    I`m new in this forum, and I have start learning VB for about 1month.

    I need help regarding one code.
    I have create a few text and combobox fields in form, and I want to IF I SELECT SPECIFIC VALUE IN COMBO BOX, THEN xxxx field must not be empty.

    I have try with this code, but I don`t know what is wrong, because the information message does not turn off when I press OK button???!!!

    Please help, and thanks in advance to helpers!!!

    if me.cboName = "john" then
    msgbox ("You have to fill ADDRESS field!", vbinformation + vbOkOnly)
    cancel = true
    me.address.setfocus
    end if

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Required field entry datat if combobox value is select?

    Welcome to the Forums.

    First suggestion, if you are just learning, consider switching to VB.Net (Visual Studio 2008/2010) because VB6 is becoming very old at this point and it may even not be supported at all by the next version of Windows.

    Regarding your problem, can you explain in more detail what you are making and what it does, I have a feeling it can be done simpler than that. Maybe send us a screenshot of your Form.

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Re: Required field entry datat if combobox value is select?

    Visual Basic.NET is a replacement of VB6. I know that VB6 is the latest one version of language, but I didnt know anything about that.
    What is the different between this .NET and VB6? At the moment I`m learning VB with MSAccess tool.

    I have add print screen. So, if you will looked at pictures. If I select ThirdParty value from combobox, then all ThirdParty field must entry data!

    Thank you...
    Attached Images Attached Images  

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Required field entry datat if combobox value is select?

    I think this will help you...
    Code:
    if cboName.Text = "john" then
      msgbox ("You have to fill ADDRESS field!", vbinformation + vbOkOnly)
      address.setfocus
      Exit Sub   '~~~> Prevents the rest of the code from executing
    end if

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Required field entry datat if combobox value is select?

    Quote Originally Posted by dejanc View Post
    At the moment I`m learning VB with MSAccess tool.
    Thread moved to 'Office Development/VBA' forum... note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    53

    Re: Required field entry datat if combobox value is select?

    It is working!!!!

    THANKS akhileshbc

  7. #7
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Required field entry datat if combobox value is select?

    Quote Originally Posted by dejanc View Post
    It is working!!!!

    THANKS akhileshbc
    Welcome...

    If that solved your problem, don't forget to mark the thread as RESOLVED (from Thread Tools found at the top of this page)

    Good luck....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

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



Click Here to Expand Forum to Full Width