Filter different query fields from different forms - ms-access

I have a query in MS Access that pretty much has every data I need for different reports. I know how to filter the query from a combo box in a form, however, I can't do it from multiple forms. Let's say for one occasion I want to filter the query from one form but for another purpose, I want to filter the same query in a different field from another form. When I try it there is a window that pops up asking for the criteria in the other field. Bear me with my English is not my first language.
Respectfully

Related

Use List Box with Multiple Selection in Query

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.

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.

How make appears a field from the field list automatically?

I just started to use Access with vba. I have table with roles, years and its workload of each role in this specific year. Each record in the table is IDRole, IDYear,Workload (number).
I display the table in a form doing a crosstab table where the years are in the columns and the roles in the rows. The number of years can increase.
My problem is when I add new years and display in the columns, it doesn't appear in the form so I have to select from the field list manually but I would like to know if there is any way in VBA that when the form is load, automatically appears the new columns (years).
I misunderstood your situation. Your form's crosstab data source is actually a table instead of a query. And as you add columns to that table, you want the new columns to automatically appear in the form when you next open the form.
In that case, use the approach described below, but where I selected a query (Query.qryFoo2) in the Source Object dropdown, choose your table ... Table.YourTableName ... in that dropdown.
The last 2 paragraphs below apply whether your data source is a table or query.
If you have your crosstab query saved as a named query, you can use it as the Source Object for a subform control.
Then when you switch from Design to Form View, the query results will be displayed in Datasheet View within the subform control.
As the number of columns changes over time, that Datasheet View can "automagically adapt" to display them ... the same as if you opened the named query directly in Datasheet View.
As far as I'm aware, there is no other reasonably simple way to accomplish what you want. If this suggestion is not suitable, you can explore programmatically adding bound data controls to your existing form after examining the set of fields the query currently returns. But that is way too much effort IMO.
I have exactly the same issue, I have a form which I use to show a Query, And I can't anticipate the number of columns from the query.
I found the same topic on other pages, and for the moment the only way I found is to build an excel file based on the query.
Another way also is maybe to directly open the crossTab query using vba.

Access: Multi-value field

I am trying to design a form where the user can search records to filter a report. The user must be able to select many values from a particular field (multivalued field). I understand I can use a list box, but the field has a total of 3,000 records and cycling through is too much. I just want to know what other ways I can let the user insert multiple values?
I have these ideas, but maybe you guys have another better way:
Creating multiple combo boxes and keep them hidden until the user hits an “add” button, but this limits me to the amount of values I can have. If I have 10 hidden combo boxes I can only enter a total of 11 (10 hidden plus the original visible) values.
Is it possible to have a temporary data grid where the user just enters the values.
Then comes the problem of getting this into the SQL Record Source. I am thinking of the SQL IN clause.
Any help or ideas, will be greatly appreciated.
I think that you should create Comboboxes where values from next combo are dynamically populated when value in previous Combo has been changed so that way you can create hierarchy of values to select.
I've done something similar for a few different applications in slightly different ways. Basically, I present the user with a table, allow them to right-click > filter (the same could be accomplished by providing a filter textbox for each corresponding field in the table you want to allow filtering on... in your case it sounds like you only need one). The filter box allows them to use 'and' and 'or' along with the actual text of what they're looking for. Then they click a button that opens the report and fills the report's filter field with whatever filter they had applied.
Of course, this assumes the user is familiar with the data they're filtering, and requires a bit of training, but for me it was a simpler alternative than displaying a list with a bajillion entries in it. Your mileage of course may vary :)

How to build the search form in ms-access

I have a ms-access database, now I need to build a search form on table "Samples" .
Now, the difficulties are I need 4 search criteria, SampleNo, SampleDate,SampleClient,SampleBatchNo.
The search criterias can work together or not.
I have a listbox to show the search results, and I want to be able to select more than one records in the results set and open a new form with the limitation of the selected records only.
Thanks
Shuolinq,
I answered a similar question yesterday here...
Populate list box from a table in vba
The only difference between that question and this one is that your rowsource will have multiple of those "Like" lines, one for each of your possible search terms and each pointing to a different control.
As for the second part of your question...opening a form using the selected results...that is a lot tougher. It can be done but only with VBA code.
Seth