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

  • SEARCH
  • Home
  • 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 8849159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:34:45+00:00 2026-06-14T12:34:45+00:00

My goal is to return the results of 5 textboxes into a SQL query,

  • 0

My goal is to return the results of 5 textboxes into a SQL query, by incorporating the Query string with the variables.

How can I get my code to function so that when a checkbox is checked, the value (eg: ID, SC…) is recorded and placed into a Query? And if a checkbox is not checked, then it is not placed into the query.

The 5 checkboxes are as follows:

Checkbox picture

The code I current have to record whether a textbox is selected, and to place the value (eg: ID, SC, AS…) into a variable is as follows:

If (Me.BoxID = False) And (Me.BoxSC = False) And (Me.BoxASSC = False) And (Me.BoxAS = False) And (Me.BoxEH = False) Then
MsgBox "You must check a Fonction Checkbox", 0
Exit Sub
Else
    If (Me.BoxID= True) Then IDValue = Chr(34) & "ID" & Chr(34) Else IDValue = """"""
    If (Me.BoxSC= True) Then SCValue = Chr(34) & "SC" & Chr(34) Else SCValue = """"""
    If (Me.BoxASSC= True) Then ASSCValue = Chr(34) & "ASSC" & Chr(34) Else ASSCValue = """"""
    If (Me.BoxAS= True) Then ASValue = Chr(34) & "AS" & Chr(34) Else ASValue = """"""
    If (Me.BoxEH= True) Then EHValue = Chr(34) & "EH" & Chr(34) Else EHValue = """"""
End If

fonctionQryString = "(((tblF.f1)=" & IDValue & ") OR " + "((tblF.f1)=" & SCValue & ") OR " + "((tblF.f1)=" & ASSCValue & ") OR " + "(tblF.f1)=" & ASValue & ") OR " + "(tblF.f1)=" & EHValue & ")))"

The fonctionQryString goes into the WHERE section of the SQL Query.

I know that the method I’m using is not efficient, even though it works.

My problem is that I don’t know how to do this another way. I want my code to function so that when a checkbox is not checked, it doesn’t go into the Query string.

Any help would be much appreciated.

  • 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-06-14T12:34:46+00:00Added an answer on June 14, 2026 at 12:34 pm

    These two WHERE clauses should produce equivalent results. Consider switching to the second form.

    WHERE tblF.f1 = "ID" OR tblF.f1 = "SC" OR tblF.f1 = "AS"
    WHERE tblF.f1 IN ("ID","SC","AS")
    

    Here is a rough and untested code sample to produce a similar WHERE clause based on my understanding of what you’re trying to achieve.

    Dim fonctionQryString As String
    Dim lngLoopNum As Long
    Dim strControlName As String
    Dim strValueList As String
    For lngLoopNum = 1 To 5
        Select Case lngLoopNum
        Case 1
            strControlName = "ID"
        Case 2
            strControlName = "SC"
        Case 3
            strControlName = "ASSC"
        Case 4
            strControlName = "AS"
        Case 5
            strControlName = "EH"
        End Select
        If Me.Controls("Box" & strControlName) = True Then
            strValueList = strValueList & "," & Chr(34) & _
                strControlName & Chr(34)
        End If
    Next
    If Len(strValueList) > 0 Then
        fonctionQryString = "tblF.f1 IN (" & Mid(strValueList, 2) & ")"
    Else
        MsgBox "You must check a Fonction Checkbox"
    End If
    

    I assumed you didn’t actually want to include the condition, WHERE tblF.f1 = "" (an empty string). If I guessed wrong, you’ll have more work to do, but hopefully this will still point you to something useful.

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

Sidebar

Related Questions

My class relationship: ClassMaster 1----* ClassSessions My Goal: Return all ClassMasters that have ClassSessions
I'm currently trying create a service that will return results of a OLAP cube
I am trying to return results that replace record Ids with their more human
My goal was to have a template function that would take as an input
My goal is to parse a class and return a data-structure (object, dictionary, etc)
Goal : I wants when I drag image it become fade so we can
Goal is to make a dialog that appears on menu_key pressed, but it keeps
Goal: Produce an Excel document with information from 3 associated models that is similar
Goal My goal is to to get Twitter Bootstrap to worth with my Play
I'm trying to put the values of a string into a byte array with

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.