473,509 Members | 8,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Report query problem

Hi

I have a report with an underlying query. The criteria is coming from a
field on the form which calls the report. So the query is 'select * from
mytable where mytable.myfield = [Forms]![myform]![myfield]'. The problem is
that the form field doe snot contain a single value like x but 'x or y'.
This does not work in a query if the form field has this value. How do I get
the report to work with two or more values connected by an 'or' operator?

Thanks

Regards
Nov 13 '05 #1
4 1324
On Sun, 31 Oct 2004 01:05:56 -0000, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Simply concatenate the entire sql statement. For example in the
Report_Open event of your report you can write:
Me.RecordSource = "select * from mytable where mytable.myfield in (" &
[Forms]![myform]![myfield] & ")"
Note that I'm concatenating 3 substrings to create the RecordSource.

The IN-clause requires comma-separated values, for example:
2,3
So that's what you would enter in your field.

Note that this is not legal SQL:
select * from mytable where mytable.myfield = 2 or 3
This should be:
select * from mytable where mytable.myfield=2 or mytable.myfield=3

Note that if you have text rather than numbers, quotes may be needed.
For example your field would contain:
'aaa','bbb'
and a sql statement with OR would read:
select * from mytable where mytable.myfield='aaa' or
mytable.myfield='bbb'

-Tom.

Hi

I have a report with an underlying query. The criteria is coming from a
field on the form which calls the report. So the query is 'select * from
mytable where mytable.myfield = [Forms]![myform]![myfield]'. The problem is
that the form field doe snot contain a single value like x but 'x or y'.
This does not work in a query if the form field has this value. How do I get
the report to work with two or more values connected by an 'or' operator?

Thanks

Regards


Nov 13 '05 #2
How do I assign the constructed sql as report data source?

Thanks

Regards
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:0b********************************@4ax.com...
On Sun, 31 Oct 2004 01:05:56 -0000, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Simply concatenate the entire sql statement. For example in the
Report_Open event of your report you can write:
Me.RecordSource = "select * from mytable where mytable.myfield in (" &
[Forms]![myform]![myfield] & ")"
Note that I'm concatenating 3 substrings to create the RecordSource.

The IN-clause requires comma-separated values, for example:
2,3
So that's what you would enter in your field.

Note that this is not legal SQL:
select * from mytable where mytable.myfield = 2 or 3
This should be:
select * from mytable where mytable.myfield=2 or mytable.myfield=3

Note that if you have text rather than numbers, quotes may be needed.
For example your field would contain:
'aaa','bbb'
and a sql statement with OR would read:
select * from mytable where mytable.myfield='aaa' or
mytable.myfield='bbb'

-Tom.

Hi

I have a report with an underlying query. The criteria is coming from a
field on the form which calls the report. So the query is 'select * from
mytable where mytable.myfield = [Forms]![myform]![myfield]'. The problem isthat the form field doe snot contain a single value like x but 'x or y'.
This does not work in a query if the form field has this value. How do I getthe report to work with two or more values connected by an 'or' operator?

Thanks

Regards

Nov 13 '05 #3
On Sun, 31 Oct 2004 03:19:52 -0000, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Re-read the first paragraph of my original reply.
-Tom.
How do I assign the constructed sql as report data source?

Thanks

Regards

<clip>

Nov 13 '05 #4
Great. Thanks.

Regards

"Tom van Stiphout" <no*************@cox.net> wrote in message
news:qm********************************@4ax.com...
On Sun, 31 Oct 2004 03:19:52 -0000, "John" <Jo**@nospam.infovis.co.uk>
wrote:

Re-read the first paragraph of my original reply.
-Tom.
How do I assign the constructed sql as report data source?

Thanks

Regards

<clip>

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1130
by: Grant Stanley | last post by:
I'm developing an application in VS.Net 2003 using C#, which uses Crystal Reports. When creating each report, crystal asks where the database to use is, so I specify our SQL server using the ADO...
3
2320
by: Grim Reaper | last post by:
I know this is probably an easy question, but I could not find/figure it out. Basically, I am printing mailing labels with a "Sorting/Grouping" section that groups the label types together....
3
2712
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
8
1836
by: David Horsman | last post by:
I have a report that lists File-B. My macro runs this report using a query as a filter. The query uses two files, the parent File-B and with a 0-many relationship to File-C. The query selects...
12
6624
by: jkearns | last post by:
Hello, I made a report from a crosstab query following the steps onlined in MSDN's Solutions.mdb example. I now have a dynamic crosstab report (great!), but with one minor problem. I cannot get...
5
3348
by: David L. | last post by:
I'm running into a frustrating problem. ASP.NET 2.0 web application, against SQL'05, I'm trying to run a report against a 'table provider' (query) that excutes well within SQL MGT studio, and...
4
3808
by: Jimmy | last post by:
I have a form with a command button on it that is supposed to open up a report and use a query to populate it. DoCmd.OpenReport "rptMailingList", acViewPreview, "qryMailingListChristmas" ...
69
8014
by: kabradley | last post by:
Alrighty Guys and Gals, I have another question that I hope you all can help me with. I have a report that uses a cross-tab query as its record source. This cross-tab query is getting all of its...
6
9377
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
12
3510
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7416
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...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
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...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.