Query Search For An Exact Value In An Exact Location
Sep 3, 2005
Background:
I have a database that keeps track of containers -what they belong to, and what is in them. Each container has a “Call #” which is labeled on the container and is a primary key in the database. The “Call #” field is set to only allow 5 characters in this field. A standard “Call #” for example is "A 152".
When a new container comes into the system, which has not been physically labeled yet, I enter it in the database a little different. So let us say container "A 152" just came in, and has not been physically labeled yet. I enter the “Call #” into the system as "MA152". The "M" tell me it still needs to be physically labeled.
When I go to label all the unlabeled containers, I print a report with all the "Call #''s that start with "M".
I have another field in the same table called "Mark". In my forms I can then go through and click a "Mark Button". The Report prints all containers where the "Mark" field = yes(True). This feature is used for a number of different reports, not just unlabeled containers. To keep the database clean and in order, all “Mark” fields reset to no(false) whenever it opens up.
Because, I used the “Mark” field for other reports, simply clicking the “Mark Button” when I enter the new container into the system will not work.
My Question:
Is There a way to have a Query search for the first letter in a field. So when I go to print my report, a query runs looking for all "Call #s" that start with the letter “M”.
How can I get an exact match in a search. If I search for say C1 I get results showing everything with C1 i.e C1, C11, C12, C13 etc. I just want to show C1's This shows my query at present.
Does anyone know how to perform an exact match using file search. The code I have below searches for the users AcroRd32.exe file (I have done it this way to allow for different versions of the reader). The problem is that foundfiles returns also AcroRd32info.exe ie FoundFiles(1). i only want to search for the prior!
Set fs = Application.FileSearch With fs .NewSearch .LookIn = "C:Program FilesAdobe" .SearchSubFolders = True .FileName = "AcroRd32.exe"
If .Execute > 0 Then 'check if there is such a file
stAppName = .FoundFiles(1) 'then define this as the applicate string name stAppName = stAppName & " " 'append a space or file string not correct 'specify path name for location of file.pdf stlocation = GetPrivateProfileString32("C:WINDOWSSSI_PROGRS_DATABASE.ini", "DIR", "DATABASE_FILELOCATION") stpathname = stlocation & "file.pdf" Shell stAppName & stpathname, vbMaximizedFocus Else 'if no file is found then need to instruct user to install reader MsgBox "You need to install Adobe Acrobat Reader to open this file", vbExclamation End If End With
I did export the table data into a tabbed delimited format and will include that at the end. If you want to reproduce my bug copy that data in a txt file and import that into the table tblMain. Make a search form and a sub form. the sub form is linked to the table and the main form is unbound with two search buttons.
Problem Statement:The code works fine. I did find a bug that seems to arise with the wild cards when the entire field values are entered. You can replicate the bug by testing the search criteria listed below.
This is a brief example of the bug. A detailed description is near the code below.
If my name is "Devtycoon" and I search "Dev" the SQL statement will build "*Dev*" and it will pull up my name, "Devtycoon". On the contrary if I search "Tycoon" the SQL statement will build "*tycoon*" and it will pull up my name, "Devtycoon". If i search "DevTycoon" the sql statement will build "*Devtycoon*" and no results will be returned. That is buggy because the name is in the database but no wildcards would be needed.
Form1 contains the controls for search criteria. Three text box controls are used to filter a sub form control called "DS". The sub form is called sFrmMain and is a datasheet that shows results of the search. there is a button that runs the code and another button that clears search criteria and shows all records. Both button's code set the sub form's record source using an SQL string built using a function that returns a segment of the overall search string using the contents of each control that then is concatenated into a SQL statement used to set the record source.
There is a function for the following components of the SQL statement
SELECT / FROM WHERE controlA = me.txtSurname controlB = me.txtOrganization controlC = me.txtProgramTitle This is how you can replicate the bug.
I tested two additional surnames organizations and program titles as follows:
Try example (1). you will get both the 4's and the 14's records returned.
If you type in letter for letter of the second record (the one with the 14's) no records populate. It is like the wild card does not like it if you type in the entire field value. Uncle Gizmo's and Allen Brown's method do the same thing were no records populate if the 14's entire surname organization and program title are entered into the text controls. Can you reproduce this error? Other than that I think either method is bulletproof.
Example criteria
1) put the following criteria in each control then hit the search button
4 surname 4 organization 4 program title [two records returned]
2) put the following criteria in each control then hit the search button
[no records returned] 14 surname 14 14 organization 14 14 program title 14
SELECT Table1.*, Table1.[Winning Contractor] FROM Table1 WHERE (((Table1.[Winning Contractor])=[Who was the winning bidder?]));
This works well except if the user doesn't captialize a letter or doesn't type in the full company name. Is there a way to change this search to a like search instead of an exact one?
Hello, i'm not sure how to write a query, maybe it'll take VBA function to accomplish this, but I need to display the results for all invoices for an item.
Little background: 1. This set of invoices are of only one particular product line as it's this product line that needs this special handling. These are Guitar orders. 2. Each guitar item can have option items on the same invoice. So basically these are all considered item numbers. 3. The guitar starts as the bare / basic guitar. The customer can choose to select one or many options for a custom guitar. 4. These orders will need to have special guitar programming codes that need to be entered into their guitar programming machines. Call these "Codes". 5. Depending on the option items for the various guitar items, the Codes could vary. 6. Need to be able to display ONLY the Codes specific to the guitar or guitar and option combinations.
I have several tables: 1. Guitar for all the guitar items 2. Options for all the option items 3. ProgrammingCodes for all the programming Codes 4. ProgramCodes for creating the above combinations with a field named ComboID. 5. GuitarHeader - the invoice number and guitar item 6. GuitarDetails - the invoice number and option item (invoice number to invoicenumber link to the GuitarHeader)
Then there's a main form and a sub-form for the end-user (guitar programmer). 1. The main form is the Guitar items 2. The sub-form is the ProgramCodes fields this form is used for this end-user select the Guitar and options (where necessary) and select the Codes and enter the ComboID for all.
for instance: These are all the possible codes for AE185. AND depending on the Options selected for AE185 on invoices, the Codes will differ. The ComboID is the differentiator. Code:GuitarOptionCodeComboIDAE185 185RR 1AE185 186RHT1AE185 187RT 1AE18538185RR2AE18538186RHT2AE18538187RT382AE185BB185RR3AE185BB186RHT3AE185BB188RT-B3AE18538185RR4AE185BB185RR4AE18538186RHT4AE185BB186RHT4AE18538188RT38B 4AE185BB188RT38B 4
so for the Codes that repeats in the ComboID is only because the Option(s) also requires that Code as well as the other Codes.
for instance, if the invoice ONLY has Option 38 from the Options defined for Codes, then the result would be:
Code:Invoice Guitar Codes123456 AE185 185RR 186RHT 187RT38 <-- say this invoice had Option 38 that was the only match234567 AE185 185RR 186RHT 188RT-B <-- because BB was the only one that matches345678 AE185 185RR 186RHT 188RT38B <-- because both 38 & BB matches
So guess the question is how do I write a query or function (VBA) to be used in a query to get the results for ONLY the matching options so the correct codes for just these options are displaying?
It's difficult to me in figuring that out. how to make sure that the result does not show the ALL the codes that match but ONLY the codes in the combinations. Again, hence the reason why I got to the point of having Combination IDs to differentiate that.
hope I made sense here. Not sure how else to ask the question other then to try and provide examples let me know how else to explain if this is not helping.
there are certain txt boxes that once filled out, will filter a subform of a table of 1000's of records to give them a number to use on the form around 200 of the records have a depot in the "depot" field on the table, when they input a depot, it filters to them 200 fine if a depot is there,
what i want is, when they input the depot, if its there, filter it, if its not, to do nothing, as they could still get a unique number if the depot isnt in the list what happens now is, if the depot isnt in the list, it displays no records
Field : Fld_Depot Table : Tbl_Agreement_Summary Show : False Criteria : Like "*" & SearchForText([Forms]![Frm_New_Accounts]![Fld_Depot]) & "*" Or : Is Null
I'm using an array with the Instr function. The array (or the Instr function) doesn't seem to be case sensitive... which is a pain because its picking words within words where the case doesn't match!! I'd like the vales in the array to match exactly when using the Instr function
For a couple of days now I've been trying to devise a way to achieve what I want, but I just keep going in circles and hitting errors (thanks to forum members, I've been able to solve most of them.) So, here's what I want to be able to do:
Input a product using the iproduct combo box (which gets its list of values from the Products table); its brand, using the ibrand combo box; and its size using the isize textbox, all in the frmFoodSub form. I then want it to check to see if an exact record already exists (ie. the same product, same brand, same size.)
If it doesn't exist, I want to create it. If it does, I want to do nothing. Then I want the product - either the one I just created, or from a record that already exists matching the iProduct input - to be input into the product field of the PurchaseDetails table. I then want to use iQuantity and iPrice textboxs, already linked to the PurchaseDetails table, to input the newly added product's quantity and price.
I hope my explanation was clear enough. I'd appreciate any help with this you may be able to offer.
Database to query. It holds tables for the machines we have and the parts each machine requires. We also have a database of spare machines and the parts that are in them.
Given the nature of the machines, some parts aren't worth trying to pull out singularly, only as part of a set.
I've been asked to put together something queries which of our old parts/machines can be reused.
So I have a table of current machines and their parts and when they were last replaced.
I have a query that says 'Show me all the machines that have parts over 5 years old.' I get a list of machines and their parts
Can I then take that whole list of parts and search the table of spare machines any parts and find that exact list of parts?
I don't mind if the machine has more parts, but it must match that exact set of parts and that set of parts should be contained in one machine.
I've added an example that is a cut down version of what I have:
Basically say we might want to replace the parts in Current machine 10002.
I query CurrentMachines for which parts it has.I then want to use the results of that to query the spares. But I only want to return spares that has all three parts that machine 10002 has.
All I can make it do at the minute is find the spares with any one of the parts that match the 10002 list.
I don't seem to find any query formula in the forum where the age changes on the date of birth. I tried all the once I could find but all of them seem to calculate the age as of 1 January. I find it a bit strange that it doesn't work.
I got BirthDate and Date in the table I want to update the age column back in the history with an update query.
I've a company database with everyone's software license but it doesn't have their employee ID number. I have another database with everyone's ID Number and I need to merge the two, How ever the problem is the names aren't exactly the same in both data bases. Some have small changes like
John, Sargent M :: John, Sargent M. Samantha, Williams Anne :: Samantha, Williams A.
It's all the people with more than 2 names entered that his problem happens the most and I was wondering how to solve this in access?
How to find an exact match in a Access DB table using Sql Query in VB6 ?I know that "Like" keyword will give out all those rows which contain the search-for-string. But I want exact match.
I have a text box on my main form, that filters records on a subform, where its record source is a query.The text box works okay for filtering, however it is not doing something that I would like it to.Say we have these records
TM STEELS TM Steels
If I was to type in STEELS, then only the top record would be displayed, likewise, if I typed in Steels, only the bottom would be displayed.What I would like, is if you were to type steels, for example, both of the records would be displayed.In the criteria of the field this is based on, in the query, I have:
Code: Like "*" & [Forms]![MainWindow].[NameTxt] & "*"
As I say, this works for bringing in results that EXACTLY match the text entered in the text box.
what I would like to do if possible is for this to look at the first line in the table but I want to use this part of the code for 4 or 5 different paths Is it possible to modify the code so when I use it 5 times each code looks at different lines in the table
I would like to create a form that allows me to search for a folder on my desk top, then once located i can transfer that file to a specific location on another drive, Similar to the Browse / upload function you see on many applications.I am using Access 2003. Is this possible??
Preface: Main table called tblMain. Here are three of the fields that I am interested in setting this up for.
tblMain Field 1: [IncidentDate] Field 2: [Address] (actually street numbers) Field 3: [CityStreet] (actually street name via lookup field off another table)
Query based of the above tables.
What I want to query is this:
If location has an entry on July 4th, 2006 then it counts it, if the same location has has another entry it counts it. If it only has a incident on July 4th, 2006 an no other prior incidents do not display it... Does this make sense.
So it would look something like this in a report generated off of the query.
07/04/06 123 Main St 07/03/06 123 Main St 05/05/06 123 Main St
07/04/06 125 South St 07/02/06 125 South St 06/22/06 125 South St
I have a table with persons age and location and I want to generate a report of all persons by location and age group. The age groups are 0-9, 10 - 19, 20 - 29..., 90-99. The location codes are 10,20,30,...90,99.
I am attempting to build a small database for my firm to keep a track of equipment. The equipment can be in one of three places. In the warehouse, out on a job or at the repairers. I want to create a query that will let me know where a piece of equipment is at any one time. I'm sure my tables are set up correctly. I have use a union query to work out when equipment is on a job or in repairs but I need one to show me where all the equipment currently is.
I have a query that combines few different tables in order to create a View (Query) that is then used to by and Excel sheet to update a list. The Excel is dynamical updated when new data is inputted in the Access Tables.
But one of the fields in a query is combination of path name and report name (another filed in one of the tables) that crate a complete path to a file that contains some additional information.
Now since the Excel is updated dynamical and users of this Excel sheet are not very advanced. I waned to make it easy for them to just click on the location of the file and the file opens up. But I am not able to make the Query that contains the file destination hyperlinked.
I am trying to export a query or table to a location that the user selects. So each time the export button is clicked the folder will change. But I want to be able to select the folder.
The code I have below is saving but not to the folder I want it to.
Private Sub CommandBtn_Click() Dim fileSelection As Object Dim strPath As String Set fileSelection = Application.FileDialog(4) With fileSelection .AllowMultiSelect = False If .Show = True Then
I have a search form that uses a query to show results of a search, but everytime I press search everything comes up even though I have entered search parameters, even though my search requeries every time and the search used to work before I added new records today. Also when I press the query alone on the navigation pane it asks me for the parameters and then it actually works but it won't when I use my form.
I have 50 locations spread over the UK and each site has a red, amber or green status based on several criteria. What i want to do is have a form with a map of the UK and have each location represented on the map with it's red, amber or green status based on coordinates in the country i guess.