472,950 Members | 2,211 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,950 software developers and data experts.

openReport

4 Nibble
Trying to open a report with multiple WHEREconditions. I have 4 strings (SelA, SelB, SelC, whereStr) all defined as strings.

SelA, SelB SelC all pieces of the whereStr

If I set whereStr = {any of the individual strings A,B or C}, the following works

DoCmd.OpenReport "rptName", acViewReport , , whereStr

When I try to concatenate the stings into 'whereStr', I only get the first string listed in the report.

Anyone? Help?
Jul 20 '21 #1
9 3625
cactusdata
209 Expert 128KB
Concatenate? How? They are there already: SelA, SelB SelC all pieces of the whereStr

And do you wish to filter on four fields or one field?
Jul 20 '21 #2
bryonone
4 Nibble
If I set
whereStr=SelA
It works fine

how do I get the whereStr to be equal to SelA, SelB, and SelC.

I want to filter on all 3 fields.

Any thoughts?
Jul 20 '21 #3
cactusdata
209 Expert 128KB
Try with:

Expand|Select|Wrap|Line Numbers
  1. whereStr = SelA & " And " & SelB & " And " & SelC
Jul 20 '21 #4
bryonone
4 Nibble
I had tried that before. It only recognizes the first string and ignores the rest. I just tried again triple checking the & and "". Still does not work.

I also tried in the 'WHERE" entry,
SelA + SelB + SelC
Jul 20 '21 #5
cactusdata
209 Expert 128KB
Without the content of SelA, B, and C, we can't help.
Jul 20 '21 #6
bryonone
4 Nibble
Expand|Select|Wrap|Line Numbers
  1. Dim SelLic, SelSW, SelArea As String
  2. Dim whereStr As String
  3.  
  4. SelLic = "[swLicName]= Forms![frmViewLicToLoc]![txtSelectedLicense] _
  5.     OR Forms![frmViewLicToLoc]![txtSelectedLicense] is null _
  6.     OR Forms![frmViewLicToLoc]![txtSelectedLicense]=''"
  7.  
  8. SelSW = "[swName]=Forms![frmViewLicToLoc]![txtSelectedSW] _
  9.     OR Forms![frmViewLicToLoc]![txtSelectedSW] is null _
  10.     OR Forms![frmViewLicToLoc]![txtSelectedSW]=''"
  11.  
  12. SelArea = "[areaLocation] = Forms![frmViewLicToLoc]![txtSelectedArea] _
  13.     OR Forms![frmViewLicToLoc]![txtSelectedArea] is null _
  14.     OR Forms![frmViewLicToLoc]![txtSelectedArea]=''"
  15.  
  16.     whereStr = SelSW
  17.  
  18.     DoCmd.OpenReport "rptViewSearch", acViewReport, , whereStr
Jul 20 '21 #7
isladogs
442 Expert Mod 256MB
Suggest you look at the code in the two example Databases from my article Multiple Group and Filter.
These are designed to show ways of building filter criteria when several filter criteria are entered
Jul 20 '21 #8
cactusdata
209 Expert 128KB
Try reducing these like:

Expand|Select|Wrap|Line Numbers
  1. SelLic = "[swLicName] = Nz(Forms![frmViewLicToLoc]![txtSelectedLicense], [swLicName])"
Jul 20 '21 #9
NeoPa
32,546 Expert Mod 16PB
Hi Bryon.

I would suggest you're getting in your own way here. Massively overcomplicating what should be fundamentally straightforward. See How to Debug SQL String for how to make this much easier for yourself. I suspect once you start following this simple guidance you will no longer need any external help.

Can we assume that you understand and recognise how a WHERE clause is formatted and works within SQL (SQL format closely matches what is expected in the WhereCondition parameter that we're talking about here from your code.)? If not then we have to look at some very basic work with you, but as you'll already have seen, we have many willing helpers who can do that as long as they realise it's necessary.

I suspect once we stop following you round in circles we can reach a solution that not only works for you, but also one that you'll understand and be able to use in future.

Best of luck & welcome to Bytes.com.
Jul 20 '21 #10

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

Similar topics

3
by: Aaron | last post by:
Hello, I'm trying to limit a report to a list of parameters that I pass in. The report and the underlying query both use the column FirstName. Whenever I try to limit the FirstName in via the...
1
by: Andrew | last post by:
Hi All: I am using Access2000 and I find that the command to open an Access report in preview mode is very slow: DoCmd.OpenReport rptABC, acViewPreview, "", "" The scenario is this: - The...
3
by: Blah | last post by:
Hello, I'm trying to use the where clause in OpenReport to limit the data return on the subreport. Is there a way to do it using that method or OpenReport only work with the report you're...
1
by: Tom Louchbaum | last post by:
Can someonw pls tell me how to reference the Where clause made by the VBA statement DoCmd.OPENREPORT "Report",acviewpreview,,where as a control within the Report itself? Thanks.
5
by: fearblanco | last post by:
Hello - I am receiving the below error message when attempting to open a report. This database is used by approximately 20 users and only one user is having this problem (even I can't duplicate...
1
by: kistemaker | last post by:
Hi, I could need your help. I am working with ACC97 as frontend and Oracle9 as database. All Queries are made as pass-through-queries. Everything looks fine, but I can't handle the OpenReport to...
4
by: Simon | last post by:
Dear reader, The syntax for Docmd.OpenReport is: OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs) Example The following example prints Sales Report while...
1
by: MLH | last post by:
Stephen Lebans has a function named ConvertReportToPDF that I use from time to time. It's quite handy, actually. In that FN is a line that reads as follows: DoCmd.OutputTo acOutputReport,...
4
by: gazza10001 | last post by:
Hi i hope you can help my company uses access and has modified for its needs usually what happens is you serach for the invoice by its number and then it brings all the information up such as...
5
by: RalphBenoy | last post by:
I have not much programming experience but would like to OpenReport in Access using a field name from a query. I have a number of different reports. I have a query that defines which report I want...
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=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
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...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
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...

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.