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 9078367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:36:17+00:00 2026-06-16T19:36:17+00:00

I want to create a query which takes field parameters through a form. For

  • 0

I want to create a query which takes field parameters through a form. For this, I created a form with combo boxes and drop down options to select the values from, this populates a text value in the respective invisible text fields whose default value I have set to null. Now in my query I give criteria for column as iif(isNull([Forms]![Conditions]![text_on_form]), [column_in_table], [Forms]![Conditions]![text_on_form]). I have done this for all the columns on which the where clause comes from the form. I have tried running this. The results seem to be random. It worked for three columns, but when I played around with it, it was giving me empty result set. Can anyone tell me what I am doing wrong? Or if there is a better way to implement query by form in Access.

  • 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-16T19:36:18+00:00Added an answer on June 16, 2026 at 7:36 pm

    It sounds like you are trying to create dynamic SQL. Here is the method in vba I generally prefer:

    Dim SQL As String
    
    SQL = "SELECT tblName.* From tblName WHERE (1=1)"
    
    If Not IsNull(Me.combo1) Then
        SQL = SQL & " And ([Field1] Like ""*" & Me.combo1 & "*"")" ' I am using like statements here, but that is because this is a search tool.
    End If
    
    If Not IsNull(Me.combo2) Then
        SQL = SQL & " And ([Feild2] Like ""*" & Me.combo2 & "*"")"
    End If
    
    Docmd.RunSQL SQL
    
    End Sub
    

    Basically, add on to the SQL statement only if the user has put a value into your text box/ combo box or whatever. The “Where (1=1)” is to account for a situation where all fields are null.

    Play with this concept to create your SQL statements. Avoid using invisible text boxes to store data, it generally means you are doing something wrong and will get mixed results (someone else on this forum can explain better than me why that is).

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

Sidebar

Related Questions

For a recent test, I want to 'create' a query which takes atleast 5
I want to make this kind of query: create procedure something @name varchar(13) as
I want DBSession.query(Article).group_by(Article.created.month).all() But this query can't using How do I do this using
I want to create a specific generic method in Scala. It takes two parameters.
I want to write a query kind of like this: CREATE PROCEDURE DupFinder @FirstName
I want to create a stored procedure which takes integer values as a @top
I want to create a handler function which takes two inputs. One is a
I have a class DBHandler which takes a query, runs it through the SQL
I'm trying to create a select box drop down with a twist, Basically this
I want to create a query that selects the columns PlayerName , PlayerNumber, Location,

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.