Hi, i have managed to filter a report based on selections made in a list box but am totally confused with a message box that appears everytime i run my report.
Let me explain (i apologise for being long-winded)...
I have a query called qry Queue Filtered SLA Position,
within this query there is a field 'Queue Group'.
I also have a report called rpt Queue Filtered SLA Position
I have a listbox called ListFilter. It's rowsource is equal to qry Queue Filtered SLA Position. The multiselect property is set to 'simple'.
I have the following code in my form : -
Private Function GetCriteria() As String
-
Dim stDocCriteria As String
-
Dim VarItm As Variant
-
For Each VarItm In ListFilter.ItemsSelected
-
stDocCriteria = stDocCriteria & "[Queue Group] = " & ListFilter.Column(0, VarItm) & " OR "
-
Next
-
If stDocCriteria <> "" Then
-
stDocCriteria = Left(stDocCriteria, Len(stDocCriteria) - 4)
-
Else
-
stDocCriteria = "True"
-
End If
-
GetCriteria = stDocCriteria
-
End Function
-
And a button to request the report which has the following code: -
Private Sub Command2_Click()
-
DoCmd.OpenReport "rpt Queue Filtered SLA Position", acPreview, , GetCriteria()
-
End Sub
-
Now, when i make a selection from the listbox and click the button i get a message box entitled 'Enter Parameter Value' with the selection i have just made above the text box! If i then type in the selection i have made and click OK, the report is produced as intended, i.e. with just my selection.
Why, oh why does this message box appear ?? What is the point of making a selection only to have to type it in ?
Your comments/advise is greatly appreciated and needed.
5 2681
I have a developement, i have realised that the problem is the 'Get Criteria()' part of the statement: - DoCmd.OpenReport "rpt Queue Filtered SLA Position", acPreview, , GetCriteria()
where the GetCriteria() is the WHERE condition. It is recognising the selection(s) as [selection] and not "selection" therefore is asking for the value.
However i am still at a loss as to how to rectify this, can anyone assist??
kepston 97
Recognized Expert New Member
I have had trouble building string criteria in the past too.
In this case I think you need to put in "" to add quotes around your listbox values. - stDocCriteria = stDocCriteria & "[Queue Group] = """ & ListFilter.Column(0, VarItm) & """ OR "
I hope that's clear!
I have had trouble building string criteria in the past too.
In this case I think you need to put in "" to add quotes around your listbox values. - stDocCriteria = stDocCriteria & "[Queue Group] = """ & ListFilter.Column(0, VarItm) & """ OR "
I hope that's clear!
Thank you very much, i knew it had to recognise it as a string and have just had chance to check this out before leaving work; great...it works!!!.
Cheers
NeoPa 32,567
Recognized Expert Moderator MVP
That's a good answer, to double up the quotes (""), but a better answer for working in SQL is to use the single-quotes (') instead for strings (NB ONLY in SQL - VBA doesn't work with them).
NeoPa 32,567
Recognized Expert Moderator MVP Sign in to post your reply or Sign up for a free account.
Similar topics |
by: William Wisnieski |
last post by:
Hello Everyone,
I have a main form with a datasheet subform that I use to query by form.
After the user selects two criteria on the main form and clicks the
cmdShowResults button on the main form, the subform returns the records
based on the two criteria. The criteria used on the main form are values
selected in two list boxes. When the user clicks on the first list box
(lstCollege), it returns values in the second list box...
|
by: diskoduro |
last post by:
Hi!
I'm trying to get help to an unexpected problem that has appeared
while I was writing a new application.
I want to opeon a report of product sales by filtering previously from
a listbox in a previous form. In the listbox I have the complete
products list and I select the ones I want to be presented in the
report. I push a cmdButton and generate a String (wherecondition)
which I use with docmd.openreport. The string is generated this...
|
by: Nathan Bloomfield |
last post by:
Does anyone know if there is any documentation which relates to Access2k + ?
or can anyone help adjust the code?
I am having trouble converting the DAO references.
TITLE :INF: How to Create a Dynamic Crosstab Report
PRODUCT :Microsoft Access
PROD/VER:1.00 1.10
OPER/SYS:WINDOWS
|
by: Scott Loupin |
last post by:
I've got two databases with similar data in them (WestSide and EastSide).
I've set up two identical reports that is filtered by date and the client
name. I'm using one form to do the filtering.
Currently, I've used queries to combine the two client lists, so when I open
the combo box, I have many names I need to scroll through until I find the
one I want.
How can I use filtering to only see clients from one database or the other,...
|
by: mstery |
last post by:
I have a report generated via an ID selection made in a dropdown on a
form. The report filters by an on click event in a preview report
button on the form. Everything in the report, including subreports,
filters perfectly, with the exception of a running sum DLookup field on
the main report. This field looks up a value in a foreign table. I'm
not clear where I'm supposed to be filtering this field, since it
obviously isn't picking up the...
| |
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I want
to look at that data and filter it based on what is in it.
I know that this could have been done with data sets and data views in
asp.net 1.1 but how is this done now in asp.net 2.0?
|
by: Zlatko Matiæ |
last post by:
Hello.
How to reference selected values from a multi-select list box, as a
criteria in a query ?
Is it possible at all?
Regards,
Zlatko
|
by: jilppe |
last post by:
I am creating a report based on a crosstab (BodyPart). This crosstab counts the number of incidents for each body part by month. However the data is for different years and I would like the user to be able to specify which year they are running the report for. The date is in the field incident_date (format dd/mm/yyyyy) and the filter criteria should only be on the year part.
I would also need the report to dynamically list the year...
|
by: paquer |
last post by:
On my Main form I have a Command Button that opens a Subform in order
to create a new Subform record.
At this point I want the subform to show only the new record being
created.
Not all the records the subform's table has.
I cannot put the subform as Data Entry because I cannot print the main
form & subform together if the subform is "data entry". (comes up
blank every time)
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |