472,985 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Where Clause with Multiple Criteria

42 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 7123
NeoPa
32,548 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
42 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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.