Use List Box with Multiple Selection in Query - ms-access

Given I've created an Access Form with a ListBox; property > other > Multi Select = Extended; which permits multiple selections.
User selects multiple items.
Clicks a button that creates a report in "Print Preview"; but this report is based on the query, and the query is based on the values in the form.
This is accomplished by using this in the query when viewing in Access Query Design View (not SQL):
Like ([forms]![padc]![V2])
Where the form name is padc and the value to compare is V2.
Previously, rather than the ListBox that might show 10 options, V2 was just a field with one value. A user would either type a partial value, such as jack*, and the report would pull every instance where this value began with jack; whether that was jack, or jackie, or jacko, or jackson, etc. The LIKE part of this permitted the "fuzzy" logic bringing about varied results. The query would run, and the report would show all the records with anything starting with jack.
My goal, really, is to have a user select one, two or three, or all the available options in this box, and have the report respond correctly.
I believe the ListBox will let me do this, provided I have all the right names in the table that is the source of the options available to choose from.
I set the listbox to "multi-select" to enable multiple selections on the form.
The form is happy. It can let me click/highlight one or several items from the list.
The query is not happy.
For the field V2, neither
Like ([forms]![padc]![V2])
nor
=([forms]![padc]![V2])
Will retrieve records to populate the report; regardless of whether or not just one value in ListBox is selected or multiple values. (Like = fuzzy, and = means exact match.)
Neither work.
Of course, if the query won't perform, then the report won't perform either.
How can I write the correct query in Access, using "Query View = Design View" and or SQL to get this to function properly?
If the answer is "it can't be done without using VBA" then please point me to the VBA solution that a 5-yr old can understand, because I have zero experience using VBA.
Folks have recommended I use VBA; specifically that I should incorporate the "IN() IN function" in some manner; but I don't comprehend this solution at all.
I admit to being ignorant; not stupid; but ignorant.

Related

Microsoft Access Form Query

I have created a form which allows users to search for data within the database via a form.
The database is restricted and the users are only able to navigate via buttons and forms.
At present, I have developed a form and a query which takes the criteria from a field within the form and then runs the query.
This is the code I use within the query to take the data from the form field:
[Forms]![Query].[refCriteria]
This code is featured under the "Criteria" section of the query design under the Ref field.
However, the query won't work when there is more than one criteria. I have tried entering the following code under the CCG field:
[Forms]![Query].[ccgCriteria]
I notice that when there are two or more instances of the above code within the same query, fails to produce any results.
Further to this, it prevents my users from querying multiple criteria which is certainly a feature that I require.
Is there a way to have any or all of the criteria potentially run via the same query? The only way I can think of getting this to work would be to create numerous queries, all of which would accept a different search criteria, but this is not a practical method.
Query will produce results if you enter both search criteria and you have rows with both fields equal search criteria. If you need to be able to search by just one criteria, leaving some of other search fields empty, use for each column criteria like this:
WHERE
[ref]=[Forms]![Query].[refCriteria] or Nz([Forms]![Query].[refCriteria],"")="" AND
[cgc]=[Forms]![Query].[ccgCriteria] or Nz([Forms]![Query].[ccgCriteria],"")=""
I'd recommend to type the criteria in SQL mode, in graphic mode Access will produce constructions much harder to understand, especially if you have more than 2 search fields.

MS Access: Passing Parameter to Subreport w/o SQL

I'm trying to find a way to pass a parameter from a report to a subreport without resorting to any SQL code or macros (my officemates are non-technical, but still have to use the Access database to run reports, occasionally making tweaks to them.)
I'm working in Microsoft Access 2013. I have a table that contains a list of investments as well as which state those investments are based in. I have a query that pulls data on Investments based on a user-entered State parameter. I then run two reports: one that simply lists the investments grouped on different categories, then a second report that summarizes the investment categories into a table. I've put the summary report at the top of the detailed report as a subreport, but I want to pass the State parameter through from the main report to the subreport so the user doesn't have to enter it twice. Is that possible without resorting to writing any SQL code or macros?
Thanks!
I think I understand what you're trying to do, but please add details if my answer doesn't make sense.
You can pass user entered information by referencing by
[DatabaseObjectType]![ObjectName]![FieldName].
If the user is entering the State value from a Form, you'd reference:
[Forms]![FormName]![State]
where FormName is the name of your form, and State is actually the name of the Form control containing the State value.
If the user is entering the State value in a prompt from a query, you'd reference:
[Queries]![Query1]![State]
where Query1 is the name of your initial query that gets the state info from the user, and 'State' is the name of that field.
You put these references in to your secondary query or report:
for example, in a second query, you can set the State field Criteria (in query design view) to be = [Queries]![Query1]![State]
so the second query will pull the State value from the first query
on a report, similar idea - you can set the Control Source of the State control (in Properties) to be = [Queries]![Query1]![State]

Invalid Field Name Access Web App

I have an Access Web App and I am currently trying to make an OnClick macro for a field on one of my views so that when it is clicked, it will pop up another view to a specific record. Currently, my Where clause reads Where: [DistrictID]=[Districts].[DistrictID]
When I go into the App and click on the field with the macro, I get a pop up stating "Invalid field name 'Districts.DistrictID'."
The one and only site I could find that mentioned this error is: http://blogs.technet.com/b/the_microsoft_access_support_team_blog/archive/2014/08/04/access-app-invalid-field-name-lt-tablename-gt-lt-fieldname-gt-error-when-using-where-clause.aspx
This site says that it is due to case-sensitivity of the Where clause. My case matches my table/field exactly (I program in other languages, so I always match case just out of habit). I have quadruple-checked my spelling anyway, and even went so far as to copy-paste the field name into my Where clause. Still I get the error.
I have another view that does something similar with a different table/view that works perfectly (Where: [ContactID]=[Contacts].[ContactID]).
Does anyone have any idea why my Where clause is not working, or what I could be doing wrong?
Extra info if needed:
I would include photos, but the information in my database is sensitive, so I will do my best to describe the information in question:
I have 10 tables in the database. "Districts" is the one I am trying to work with. The Districts table has... quite a few fields, including DistrictID, DistrictName, EmailService, SpecialComment, and more. These four however are the fields being queried for the datasheet view which contains the macro. The OnClick macro is triggered for the SpecialComment field - when clicked, I want my District List view to pop up to the same district whose SpecialComment was clicked on (the Special Comment can run long sometimes, so if it is cut off by the size limit of the datasheet, I want people to be able to read the rest of the info without having to switch to another view and then find the district in the list). The District List view and the queried view both have the DistrictID field in the view, although it is hidden. I have tried unhiding the field in both views and it did not solve the problem - I had other Where clauses that used the DistrictID field before this that worked fine, so I doubted it would change anything anyway. Those Where clauses from before were substituted for other functions, so I don't have them to refer to to see why that one worked and this one does not.
If the view you are trying to open using OpenPopup macro action has a saved query as it's record source, then you must use the query name like this:
[FieldNameHere]=[NameOfQueryHere].[FieldNameInThatQuery]
If you are using a table name, then substitute the actual table name in the appropriate spot.
One thing to note which sometimes trips people up is that this technique won't work if the view you are trying to open uses an Embedded Query as its record source. The reason for this is you have no way of knowing what the embedded query name is that Access creates behind the scenes for the Access 2013 web app view. (It's actually a GUID name behind the scenes.)
I even had to add a special troubleshooting note in my book on this since I knew people would get tripped up on this (Page 584):
TROUBLESHOOTING
Why do I get an error trying to use a Where clause with an OpenPopup or ChangeView action when the view is based on an embedded query?
Access Services requires the Where clause to include the table or query name on which the view is based. When you define an embedded query as the record source for a view, Access Services creates a hidden system query that is not visible in the Navigation pane. Therefore, you cannot use a Where clause with the OpenPopup action or ChangeView action to open a view based on an embedded query. To work around this limitation, you can base your view on a saved query object. Note that Access Services creates a hidden system query as the record source also for Summary views. This means that you cannot use the Where clause argument to open a Summary view to a specific record or set of records. However, the workaround mentioned above won't work for Summary views.

Storing multiple parameter values in another parameter in SSRS

I am trying to develop a report in SQL Server Reporting Services using parameters.
I have created a searchable parameter (as described in the link below) which is working as it should. I want to expand the functionality so that I can make multiple searches before viewing my report.
My problem is that when I have searched and selected a value and seach for another value the selected is reset (this is because the parameter where I select is cascading to the one where I search). Is there any way I can 'save' my selected parameter so that I, in the end, have all the seached and selected values which I then can filter on?
Searchable parameter: http://romiller.com/2008/07/29/searchable-dependant-parameters-in-ssrs/
(My problem is the same as Peter Schmidts comment in the link above.)
Thanks
The only way I can think of to get the results you desire is to create separate dataset with a required parameter that depends on a search term from the other parameters...this is very hackish and requires a search on multiple values stored procedure. This would cause the report to postback after you select your search criteria then display another parameter dropdown after a second refresh where the user could select the desired id based on search terms and then finally clicking the "view report" button a second time.

BOBJ Webi Prompt with a specific subset of values

I'm creating a webi report and have a few prompts defined at the query (not universe) level. Unfortunately, the prompts return a butt load of values due to the design of the table. What I'd like to do is restrict the list of values presented to the user based on a set of criteria. Is there any way to do this in the query? I'd like to avoid creating a specific prompt in the universe.
Thanks
In XI3, there's no way to do this without touching the universe. In the universe, you can modify the LOV logic for a particular object -- click the "Properties" tab, then "Edit" under "Associate List of Values". This will present a standard query panel; you can add conditions here, and the conditions will be applied whenever the LOV is displayed in WebI. Note that this action will only affect the display of the LOV; it will not have any effect on how the SQL is constructed to generate the report.