473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Where Clause with Multiple Criteria

43 32bit
Well! I have a list called List537 and I want to show two number of columns in it, after entering my value (number) in an unbound text box. I know how to get data source in the list with a single WHERE clause however, I want to use multiple criteria to get accurate results. I have a table called "Objectives" where two columns are exists i.e., Number and Question. I want to show them in a List537 wherein quantity of bounded columns are two with the size of 1";2". I have write the code below but facing "syntax error".

Expand|Select|Wrap|Line Numbers
  1. Me.List537.RowSource = "SELECT [Objectives].[Number],[Objectives].[Question]FROM " & _
  2.         " Objectives WHERE [SubjectID]= & Me.SubjectID And [ClassID] = & Me.ClassID" & _
  3.         " Order By Number"
Please anybody help. Thanks in advance.
Nov 19 '22 #1

✓ answered by NeoPa

Hi Aftab.

I wish I had a pound for every question where someone asks why 'X' doesn't work and they don't even include 'X' in the question - just an isolated selection of code that produces whatever 'X' is. We can never know what 'X' is because there are various references to variables of one type or another we have no information about.

So, I get your frustration when you are struggling with something, but please at least try to get the basics of the question down.

In this case it's clear that the last line (ORDER BY) can't work as you've used a reserved word (Number) without qualifying it in any way so it has no way of knowing you're trying to reference a Field in your Table, so obviously that will certainly fail. There may be further problems we could help with if/when you post the actual value you're trying to assign to Me.List537.RowSource, but they'll have to wait till we have such information.

2 7214
NeoPa
32,556 Expert Mod 16PB
Hi Aftab.

I wish I had a pound for every question where someone asks why 'X' doesn't work and they don't even include 'X' in the question - just an isolated selection of code that produces whatever 'X' is. We can never know what 'X' is because there are various references to variables of one type or another we have no information about.

So, I get your frustration when you are struggling with something, but please at least try to get the basics of the question down.

In this case it's clear that the last line (ORDER BY) can't work as you've used a reserved word (Number) without qualifying it in any way so it has no way of knowing you're trying to reference a Field in your Table, so obviously that will certainly fail. There may be further problems we could help with if/when you post the actual value you're trying to assign to Me.List537.RowSource, but they'll have to wait till we have such information.
Nov 19 '22 #2
Aftab Ahmad
43 32bit
OMG! Thanks NeoPa. I completely understood. Now, its working fine. Thanks again
Nov 20 '22 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Barry Edmund Wright | last post by:
I would really appreciate your assistance. I am using Access 2000 to create a form that Lists Names and Addresses based on a number of selection criteria one of which is a combo box cboPCZip. All...
4
by: ShyGuy | last post by:
I have a table with 4 fields. Three are used for criteria. I can get the DLookup to work with 1 criteria with the following but can't get it to work with 2 or three. NumofAppts = DLookup("",...
1
by: BerkshireGuy | last post by:
Hello everyone, I am reading a query's SQL string and adding criteria to that and then resaving it. I know, might not be the best method, but it seems to work and there are some pros to doing...
2
by: dskillingstad | last post by:
I'm trying to set up a parameter query based on an unbound form. This search form has about 5 text boxes where the user can type in values within each box and search a specific table based on the...
2
by: Jim.Mueksch | last post by:
I am having a problem with using calculated values in a WHERE clause. My query is below. DB2 gives me this error message: Error: SQL0206N "APPRAISAL_LESS_PRICE" is not valid in the context where...
1
by: 2D Rick | last post by:
I want to open a report using OpenReport and passing it a Where Clause with multiple criteria. I know the Where Clause below is way off but it conveys what I need. Dates are of string type. ...
1
by: mtnbikur | last post by:
Lots of reading out there says you should only place “join criteria” in the join clause. That makes perfect sense. What about other search criteria? I’ve got other criteria, ie. cst_delete_flag =...
0
NeoPa
by: NeoPa | last post by:
Intention : To prepare a WHERE clause for multiple field selection, but to ignore any fields where the selection criteria are not set. ONLY WORKS WITH TEXT FIELD SELECTIONS. Scenario : You have...
2
by: AnnMV8 | last post by:
Hi, I'm hoping someone can help me. I'm not a programmer but found this really nice piece of code that I have been using but it needs to be altered. I had been getting help from Microsoft's...
3
by: CD Tom | last post by:
To save some code I would like to put a distinct clause in the criteria for a report. I've created a table that I'm using for multiple reports but in some of the reports I only need one instance of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.