473,769 Members | 6,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with "WHERE-IN" statement in SQL

40 New Member
Hello,

I have an access report with WHERE clause: "WHERE tMonth in (Forms!frmMain! txtMonths)"

when txtMonths = "7" (f.e.) it works just fine, but when I try to execute the code when txtMonths = "7,8" it displays empty report

Any idea what can be wrong?
Sep 3 '07 #1
5 2522
FishVal
2,653 Recognized Expert Specialist
Hello,

I have an access report with WHERE clause: "WHERE tMonth in (Forms!frmMain! txtMonths)"

when txtMonths = "7" (f.e.) it works just fine, but when I try to execute the code when txtMonths = "7,8" it displays empty report

Any idea what can be wrong?
Hi, there.

The idea is that "7,8" is being treated as single value, not as list of values.
Try to generate SQL statement in VBA using string concatenation and then either put it to Report.RowSourc e or QueryDef.SQL of the query the report based on.
Sep 3 '07 #2
Stwange
126 Recognized Expert New Member
Hello,

I have an access report with WHERE clause: "WHERE tMonth in (Forms!frmMain! txtMonths)"

when txtMonths = "7" (f.e.) it works just fine, but when I try to execute the code when txtMonths = "7,8" it displays empty report

Any idea what can be wrong?
You could try this instead, it should work I think:

WHERE (Forms!frmMain! txtMonths) LIKE '*tMonth*'

If it doesn't work (I'm not sure if * matches an empty string or not), you might need two ORs, ie. *value*, *value and value*, but I doubt it.

Hope this helps.
Sep 3 '07 #3
saddist
40 New Member
The problem is that SQL statement is too long and it places 9 at the end of string and stops adding :/
Besides I can't change recordsource of report. When I try to do that I either get message "can't change row source becouse report is not open" or "u can't change row source when report is open or printing".
I can only change recordsource while in design view, and I dont want user to be is design view...
Sep 3 '07 #4
FishVal
2,653 Recognized Expert Specialist
The problem is that SQL statement is too long and it places 9 at the end of string and stops adding :/
Besides I can't change recordsource of report. When I try to do that I either get message "can't change row source becouse report is not open" or "u can't change row source when report is open or printing".
I can only change recordsource while in design view, and I dont want user to be is design view...
Open the report with
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport WhereCondition:="tMonth IN (" & Forms!frmMain!txtMonths & ")"
  2.  
Sep 3 '07 #5
JConsulting
603 Recognized Expert Contributor
Hello,

I have an access report with WHERE clause: "WHERE tMonth in (Forms!frmMain! txtMonths)"

when txtMonths = "7" (f.e.) it works just fine, but when I try to execute the code when txtMonths = "7,8" it displays empty report

Any idea what can be wrong?
It's been my experience that you can't pass a string to an IN() clause. You whould create an OR statement instead.
Sep 3 '07 #6

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

Similar topics

9
4401
by: LRW | last post by:
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit,...
6
17731
by: Ron Brennan | last post by:
This is from an application and not an Applet. I believe it goes to stdout but when I do a test and write an abitrary string and then do a search of the hard disk for the string, I can't find it. So, I suspect one has to create the file manually before using it. But I'll be damned if I can remember where. Thanks to anyone who'll take a few minutes to let me know.
0
4101
by: Yann GAUTHERON | last post by:
Hi, ID_LOGIN is an integer Can anyone say me if this : WHERE index1=ID_LOGIN OR index2=ID_LOGIN must be slower than those 2 queries :
5
1910
by: Ralf Wahner | last post by:
Dear Masters of XML As I'm new to XML Schema I dare to ask a possibly recurring question: Given an element <elem> with two attributes @a and @b. The attributes are bound by the condition, that either both or none must be present, i.e. <elem a="val_a" b="val_b"/> or <elem/> is valid, whilst
10
7595
by: joshsackett | last post by:
I am starting an encryption project for my database and I'm performing some tests on decryption speed. A lot of my application queries use a LIKE parameter in the WHERE clause. To keep from changing my application I am performing all the work on the back-end; creating views, triggers and UDFs to encrypt/decrypt the data. A problem has arisen around the LIKE parameter, though. Currently: SELECT SSN, FNAME, LNAME FROM USERS WHERE LNAME...
3
14939
by: bughunter | last post by:
IMHO, statements like this is mistake typically. May be more better made this construction - I said about empty WHERE - invalid? A lot of data will saved... :-) Andy
13
2822
by: andro | last post by:
Hi everybody! I have several tables from which I want to exract the SAME value (along with other referenced data). All the values are in the same column within the tables. How can I achieve this? TIA. Andro
5
5108
by: davehansen22 | last post by:
Is there a way to generate a MySQL WHERE clause from a search string like this: "(dave OR hansen) php programmer" I would want to use the generated MySQL clause against a "memo" type field. I searched but apparently I'm not using the right keywords.
0
3938
by: niklang | last post by:
Hi everybody, First post but i really need some help with this as its driving me mad. I need to format a number to be a currency and when i saw that this was supported already by the string.format function i got very excited. However, if i do: int number = 1; formattedstring= String.Format("{0:C}", number);
5
1247
by: John Nagle | last post by:
Does text = unicode(text) make a copy of a Unicode string, or is that essentially a free operation if the input is already Unicode? John Nagle
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.