473,657 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Like Filter in Query Based Form

DJRhino1175
221 New Member
I have a form I open to close out a Reject Tag Number. I have the underlying query where it asks for the Reject Tag Number to be closed. My question is can this have more than one and if I have it set up for more than one but only need one how would I code that?
Here is what I normally put in the query
Expand|Select|Wrap|Line Numbers
  1. Like [Enter Reject Tag Number]
Thanks a million for your guidance
Jul 28 '22 #1
19 12973
NeoPa
32,568 Recognized Expert Moderator MVP
Hi DJ.

I'll work with what you've posted, but for a clearer, fuller answer you may need to explain your situation (a lot) more clearly.

The SQL term Like is designed for use with wildcards. For flexibility it can be used to match an individual item but if you are looking at that then = is the more appropriate term to use.

SQL also has an In() operator which takes a list of comma-separated items and matches if any are found.

To determine how to incorporate that into your scenario would require me to have an understanding of it not afforded by your description.
Jul 28 '22 #2
DJRhino1175
221 New Member
Neo,
I click on a button that opens a form based on this query. I would like to filter that for based on a number or multiple numbers, it all depends on how many "Tags" I need to close out. Right now when I open it all open "Tags" will be available in the form. I would like to filter it to the "Tag" numbers I need to close out. It could be one "Tag" or Multiple "Tags" Normally I would use "Like [Enter Reject Tag Number]", but this will only give me the one "Tag" to close out. Then would need to hit refresh to do the next one. was hoping to see if there was a way to do this. I tried adding multiple "Like [Enter Reject Tag Number]" in the query under the or section but that did not give me multiple entries just asked for one.

Hope that clears things up more.
Jul 29 '22 #3
NeoPa
32,568 Recognized Expert Moderator MVP
Hi Rhino.

DJHRhino1175:
Hope that clears things up more.
Not in the least. You've repeated what you've already said without giving any indication of where the data comes from that you would like to filter on; how you are currently, and expect to, invoke the Form to use this; how you expect the user to specify multiple tags for you to work with.

My intention was not to give you chapter & verse as to what you should be doing before posting a question, but to encourage you to consider that for yourself before ever posting the question in the first place. What information will someone need in order to assist you? That's your question. Your responsibility.

I'm happy to help with technical problems that you struggle with. Less happy to do the basic work for you - because you can't/won't.
Jul 29 '22 #4
DJRhino1175
221 New Member
The data comes from an earlier stage in the process. I tag is created when a product needs to be reject due to a defect or whatever. The product gets looked and a manager will examine it to see if it needs to be reworked or scrapped out. Once this is done a tag or multiple tags will be turned into me or one other person to close. When I go in to close a tag I click a button to open a form to close out this tag or tags. I would like a parameter box to open up and ask me to enter a tag number. Which I already know how to do and can do very easy using "Like [Enter Reject Tag Number]" in the under lying query. I was hoping for guidance on how to do something similar to this but for multiple tags. Could be any where from 1-10 tags, maybe more. I don't need you to do the work for me, I'm just stumped on ho to get it to ask me for more than one number, but if I only have 1 number I don't want it to throw an error message out.

Here is the underlying SQL from the query

Expand|Select|Wrap|Line Numbers
  1. SELECT [Reject Tags].*
  2. FROM [Reject Tags]
  3. WHERE ((([Reject Tags].CANCEL)=False) AND (([Reject Tags].Closed)=False));
As you can see the form when open will give me all tags that are still open and not cancelled. I would like to narrow down to just the tags that I need to close.

Thanks
Jul 29 '22 #5
zmbd
5,501 Recognized Expert Moderator Expert
@DJRhino1175
guidance on how to do something similar to this but for multiple tags
You're going to have to use a form and a bit of VBA.
At least in Access2003 and above there is the TempVars object https://docs.microsoft.com/en-us/off...ccess.tempvars that I use for batch update/delete operations... if I'm lazy I just use a ForEach() loop... feeling a bit more enthusiastic I build an SQL string and the In-Operator and then execute the SQL.
The one thing I like about the ForEach() loop and the TempVars() is that I can set a progress bar (really simple one) or count-down... sometimes there are dozens of records and it gives a bit of user-feedback so they don't force quit.

Thing is, how do you want to get the tag information from the user?
1) Simple text box that I parse the string - I've moved away from this
2) Simple text box that accepts only one sample-id at a time...
3A) Form where they select the record, the button runs a "lookup" against the TempVar and if the record id isn't there then appends the value...
3B) or appends to the string that's being built for the In-Operator.

In (3B) sometimes I'll use the IN() on a SELECT to show a popup-form with the selected records and they have to click on confirm.

clear as mud?
Sometimes the voices in my head understand me better than I do👾
Jul 29 '22 #6
DJRhino1175
221 New Member
zmbd,

I receive a paper sheet from the sort area and this is where I get the Tag/ID Number from.

I think I like the 2) idea, it might be the easiest for when I'm not here for another user to use.

Thanks
Jul 29 '22 #7
NeoPa
32,568 Recognized Expert Moderator MVP
Hi Rhino.

DJHRhino1175:
I don't need you to do the work for me, ...
Strangely enough, I'm happy enough to get down and do some of the work for you. Not all, as that would be wasting both of our times. What I need you to do, and this is a much better stab at it to be fair, is the work beforehand involving consideration of how to express the question such that I have enough information to help you.

To be fair I actually do understand how difficult this can be for most people. My nudging you is nevertheless doing both of us a service. Knowing how to ask a question intelligently can be enormously helpful for you as an individual.

Now, I said the info was better now, and it is. Let's see what I can offer to help guide you towards a better understanding of how you can go about this.
DJHRhino1175:
I'm just stumped on how to get it to ask me for more than one number, ...
This is the crux of the matter. Usually I'd want to ask you to tell me what approach you're taking, but I can see that this is where you're stuck so let's see what we can offer.

There are a number of possible options. I was hoping to avoid having to spell them all out but we work with all levels here and if that's what you need let's give it a go.

Before I start though, while In(Val1,Val2,.. ., Valn) works perfectly well for separate values such that all individual items are matched, this does not work for a single string passed from a prompt which just happens to include values with commas. Values passed that way (using the prompt and square brackets[]) do not get parsed by SQL so can only be treated as a simple string value.

To illustrate, the following will not match 1, 3 & 5 separately - but only a string value of "1,3,5" when that string value is entered when prompted :-(
Expand|Select|Wrap|Line Numbers
  1. WHERE [MyField] In([Please enter 1,3,5])
This is a nuisance as it means the simplest approach is denied us :-( We will either need to prompt more professionally using a Form, or at least use some VBA to do some of the parsing ourselves to get the filtering you want.
  1. InputBox()
    This approach is not recommended as it either allows the operator to f^Hmuck things up for you, or alternatively forces you to do extra validation of the entry.

    Anyway, if you prompt the user to enter a list of values separated by commas then you can use that to filter the Form.
    Expand|Select|Wrap|Line Numbers
    1. strFilter = "Please enter all desired [Reject Tag Number]s " _
    2.           & "separated by commas."
    3. strFilter = InputBox(strFilter, "RTNs")
    4. strFilter = Replace("In(%F) And Not ([CANCEL] Or [Closed])" _
    5.                   , "%F", strFilter)
    6. Call DoCmd.OpenForm(FormName:="YourForm" _
    7.                   , WhereCondition:=strFilter)
  2. ListBox
    This involves populating a Multi-Select ListBox on an earlier Form with only those items from the table you want the operator to be able to select from (Not ([CANCEL] Or [Closed])). This still involves parsing the data yourself with VBA.
    Expand|Select|Wrap|Line Numbers
    1. strFilter = ""
    2. For Each varItem In Me.YourListBox.SelectedItems
    3.     strFilter = strFilter & "," & varItem
    4. Next VarItem
    5. strFilter = Replace("In(%F) And Not ([CANCEL] Or [Closed])" _
    6.                   , "%F", Mid(strFilter, 2))
    7. Call DoCmd.OpenForm(FormName:="YourForm" _
    8.                   , WhereCondition:=strFilter)
  3. Form
    This would involve storing your selections in a table. This could be a new Boolean (Flag) Field within [Reject Tags] or more tidily in a separate table created for this specific purpose. Whichever approach is used you must remember to reset any previous selections before use. I won't tell you how to design such Forms at this stage but we can get into those details later if you decide you need to.
    1. Within [Reject Tags]
      Once your new special Form has been closed and the selection data updated :
      Expand|Select|Wrap|Line Numbers
      1. strFilter = "[YourNewFlag] And Not ([CANCEL] Or [Closed])"
      2. Call DoCmd.OpenForm(FormName:="YourForm" _
      3.                   , WhereCondition:=strFilter)
    2. New Table
      Once you new special Form has been closed and the selection data updated :
      Expand|Select|Wrap|Line Numbers
      1. strFilter = "In(SELECT * FROM [YourNewTable]) And " _
      2.           & "Not ([CANCEL] Or [Closed])"
      3. Call DoCmd.OpenForm(FormName:="YourForm" _
      4.                   , WhereCondition:=strFilter)
You can probably see now why I wanted a clear understanding of exactly where you were in your thinking before answering, so I didn't need to cover so many possibilities. Much easier for me to produce, and also easier for you to get to grips with. Now it's up to you to consider carefully which of these approaches will work best for you and then we can fill in any further gaps of detail you may need.
Jul 29 '22 #8
DJRhino1175
221 New Member
Wow, I see this is going to be way more complicated hen I was thinking. I will give it my best shot to see where it takes me, if I run into anything I can't figure out I'll reply back. I think I'm going to try # 3.

Thanks for the guidance.
Jul 29 '22 #9
zmbd
5,501 Recognized Expert Moderator Expert
@NeoPaListBox
This involves populating a Multi-Select ListBox on an earlier Form...
silly me... I use this in the student-roster database and in one of my Batch databases at work.
Personally, I find that it works best if the user doesn't have to scroll - I'll set these up along the lines of a cascading combo/drop-box to filter down to under 20 or so items.

For larger lists I'll use a continuous form and the double-click event in the record to store the selected record id to either the string I'll use to build the SQL-IN() for DB.Execute() or to the TempVars() collection for the ForEach(). I like either of these because I can GUI feedback about records effected and/or progress

I've also used a field in the table, default 0, and checkmark control in the form to set the field to -1. Command button to db.execute stored delete-action-query that deletes all records where the field value is -1. It's an OK method; however, I've found sometimes when I have to delete related records (because I don't use cascade-delete) the application will appear to stall... for my experienced staff, they've learned to just walk away for a few minutes when that happens.
Jul 29 '22 #10

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

Similar topics

3
6605
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt for the parameter. How do I get by this problem? Do I need to create a temporary table? I rather...
7
2267
by: J-P-W | last post by:
Hi, in the past I've spent ages writing VB routines to get around this problem, is there a simple way? I have three tables for a membership system: tblMembership - MembershipNumber; Names etc tblMembershipSubsHeader - "AmountDue" ; whether the pay by standing order and so on tblMembershipSubs - PaymentYear ; DatePaid; AmountPaid
5
10264
by: Ferasse | last post by:
Hi, I'm an occasional Ms-Access developer, so there is still a lot of stuff that I don't get... Right now, I'm working on a database that stores contractual information. One of the form that I created is based on a query that links several tables. When I try to insert a record in this query-based form, I can only update the fields that are used to build relations with other tables.
1
1194
by: samtymom | last post by:
I have a database that is used for Salvage Vehicles. (At present I am using 2002, but will be moving to 2007 shortly.) Presently there is a Switchboard that opens the Form View of the Salvage table. I need a "Popup Form" to open where "Non-Access" users can enter one of 5 or 6 different fields and then have that vehicle show in the Form view with all it's data. They may enter one of Unit #, Serial8, License Plate, etc... Could...
5
3684
by: erog | last post by:
Hello I've tried using the MS Access Northwind sample DB and I've downloaded a few other sample Microsoft Access DBs from their website. I keep on running into the same problem for trying to retrieve user input from a query form. In the Northwind DB, there is a query named "Invoices Filter". In the criteria for the OrderID field in the Invoices table, the following is entered: !! I understand that for this field, it's trying to...
3
1264
by: Pookaroo85 | last post by:
SET-UP: I currently have a form with unbound text fields to type in the criteria. Then, I have a query with the criteria referencing those text fields. On the form, I have a 'Report' command button to print preview the report. GOAL: I have a form that filters a query to then print a report. There are two sections in the form: one for Start Date and End Date, the other for a material number. I would like the option to do the following...
2
1375
Brilstern
by: Brilstern | last post by:
Ok I will try to simplify this as mush as possible. I have a table: tblTotalHosts Field DataType ID AutoNumber TotalHosts Number Region Text ReportMonth Text Report Year Number
5
3710
by: Sandy1992 | last post by:
Hi friends, I am using A2010. I have completed preparing the whole application but stuck with reports. what I want to do: There is 1 command button and 1 textbox/combobox(happy if works with any of the control) . When I type employeeId(which is numeric) in that control and click on command button, it should filter the query and display the result in report. It sounds easy , but not for me. I tried lots of ways to get it done. But from...
1
8878
by: jackjee | last post by:
Hi I have a continuous form based on crosstab query results. The fields in the form is from the crosstab column headings. I am looking for updating the records directly from the form such as on click of that item in the record need to be updated from a pop up/or values placed on the form header (as textbox or command buttons) The structure of the record is like below The column headings are such as Date, Apple, Orange, Mango Date ...
0
8395
marktang
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...
0
8310
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,...
0
8826
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, 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...
1
8503
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,...
0
8605
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 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...
1
6166
isladogs
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...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.