Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4001440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:54:19+00:00 2026-05-20T07:54:19+00:00

Using VB6 I am using checkbox and combobox in a Form. When i click

  • 0

Using VB6

I am using checkbox and combobox in a Form.

When i click the check box, the combobox will enable, by default combobox will be disable.

Code.

Private Sub chkbox1_Click()
   combobox1.enable = true
End Sub

Private Sub chkbox2_Click()
   combobox2.enable = true
End Sub

Output Code is

If chkbox1.Value = 1 Then
    sql2 = "Select * from table1 where value = '" & combobox1 & "' "
ElseIf chkbox2.Value = 1 Then

    sql2 = "Select * from table1 where value = '" & combobox2 & "'"
Else 
    sql2 = "Select * from table1"
End If

The above code is working, but when i click the two checkbox, then two combobox are enabled, then i run the query it is showing the combobox1 value.

For example

I selected the value = 50 from combobox1 (checkbox1 clicked)
I selected the value = 100 from combobox2 (checkbox2 clicked)

when i run the output code, then output is display the value where value = 50, it is not showing value = 100 also.

It should show both values in the output code

How to solve this issue.

Need vb6 code help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:54:20+00:00Added an answer on May 20, 2026 at 7:54 am
    If chkcombin1.Value = 1 And chkcombin2.Value = 0 Then
        sql2 = "Select * from table1 where value = '" & combobox1 & "' "
    ElseIf chkcombin2.Value = 1 And chkcombin1.Value = 1 Then
    
        sql2 = "Select * from table1 where value = '" & combobox2 & "'"
    ElseIf chckcombin1.Value = And chkcombin2.Value = 1
        sql2 = "Select * from table 1 Where value = '" & combobox1 & "' and value = '" & combobox2 & "'"
    Else
        sql2 = "Select * from table1"
    End If
    

    What is happening is if both are checked the first case is true, since chkcombin1.Value = 1
    So you need to check to make sure that the other box is unchecked.

    Edit op comments

    Since you have multiple checkboxes then I would suggest this:

    this isn’t tested nor is it optimal but it should give you an idea

    Dim select As String = "Select * from table 1"
    
    'This needs to be a field for the whole class
    Dim where As String = ""
    
    If chkcombin1.Value = 1 Then
       where += CreateCaluse(combobox1)
    End If
    
    'Then do that for each of your comboboxes
    
    'Then
    sql2 = select + where
    
    Private Function CreateClause(ByVal comboboxValue As String) As String
        If where = "" Then
            Return " Where value = '" & comboboxValue & "'"
        Else
            Return " and value = '" & comboboxValue & "'"
        End If
    End Function
    

    SO what that does is writes the no checkboxes checked part of your statement, then it prepares the where clause, using a function to generate the necessary parts, if the where clause is an empty string it writes what it should be for 1 where, then appends all of the necessary and clauses. Finally it combines the statement together. If there is nothing in the where clause then you get the Select * from table1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using VB6 & Crystal Report 9. Need help with the VB6 code. When i
Using VB6 using Textbox in my form. I want to limit the Input in
How to check the current keyboard's language using vb6 ? IF (Is it the
I am using VB6 and the Win32 API to write data to a file,
How exactly using VB6 can I can call any Windows shell command as you
I'm working on the creation of an ActiveX EXE using VB6, and the only
I'm using a VB6 PictureBox on my User Control. I set the PictureBox's picture,
I am trying to uncompress some data created in VB6 using the zlib API.
A VB6 application is using the Interop Forms Toolkit to work with forms written
Im having trouble using a .NET COM in vb6, It compiles ok and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.