Code:
SELECT Table1.[Material Key], Table1.[Material Name], Table1.[Info]
FROM Table1 INNER JOIN search_MaterialKeys ON [Material Key] = search_MaterialKeys.[MaterialKeySearch];
So at the moment, users paste material numbers in the search_materialKeys table and the query is created with the necessary information. If the number they paste into the search_materialKeys table is not found in Table1 then the query doesnt return anything. I need the query to list all the entered values in the temptable in the query so that users know which of their inputs were not found. Is there any way to do this?
Any way to build something into a sub-query that says 'if no records are found, return '0' or some other string'?
Otherwise is there a way to make a master query ignore sub-queries if they return no records?
Allow me to explain in more detail: I have a series of sub-queries, most of these take the sum of several fields from a number of different tables, and I have a main query which combines all of these, to be used as the basis of a summary report.
These queries aren't a problem, but I have a few other essential queries which take the modal (most common....) entry for fields which aren't numerical. So I can't use the sum function.
Now, if all the sub-queries are working then so does the main query, however if one of them fails to find a result, then none of them show up in the main query. I don't know why.
The issue is that depending on the date range selected, some of the tables targeted by the sub-queries don't have any records at all, so when they are run they return nothing. The sum queries can handle this since they just return 0, but those searching for modal records just find nothing (not 0's and not null fields, just blank across all rows).
Here's an example of my sql statement for the modal queries.
Code: SELECT TOP 1 Trends.Trend AS ModeTboxTalk, "1" AS [Key] FROM Trends INNER JOIN [Toolbox Talks] ON Trends.TrendID = [Toolbox Talks].TrendID GROUP BY Trends.Trend, [Toolbox Talks].TrendID, [Toolbox Talks].TalkDate
HAVING ((([Toolbox Talks].TalkDate)<=[Forms]![WeeklyReportSelect]![WeekBox] And ([Toolbox Talks].TalkDate)>[Forms]![WeeklyReportSelect]![WeekBox]-7) AND (([Toolbox Talks].SiteID)=[Forms]![WeeklyReportSelect]![SiteBox]))
ORDER BY Count([Toolbox Talks].TrendID) DESC;
- FYI the weekly select form is where users select the week and site they want to report against. So it would be really peachy if I could tell the above to say something like 'no trend this week' if indeed there were no records.
I am setting up a database to hold staff details, and would like a query to show each member of staff's total hours and FTE.
Staff name etc is in tblStaff Staff shift details are in tblShifts linked via staffID
tblShifts will contain details of the shift worked on each day of the week, but the majority of our staff work a standard shift - e.g 8-4, 9-5. Therefore what I wanted to do was in tblStaff set a field named shiftPattern to 1 2 3 or 4. 1 indicating a custom shift, and any other number indicating a set shift defined in a separate table.
The problem I have is that my query only returns people who have details in tblShifts - regardless of their shiftPattern value. If I enter a blank record in tblShifts it will do the above as intended.
Hey everyone, Even though I'm going to feel like a moron for not knowing this I'm hoping there is a simple answer. I'm far from a master at access, and seem to be having a little trouble when it come to formatting the output of my query. I have a database made the keeps track of about 200 hundred crime reports. I want to be able to do a query that will output the 15 possible crimes as rows, and then have 4 columns which are the locations of where the crimes happened. And then for the results have how many of crime where commited there. Pretty much in an excel format (see below example). However there are some crimes that have never happened. So there are no records of them. Unfortunatly when i do my query since there are no records, they are not even listed. I need them to list the crime, and place zeros if there are none. Since this probably isn't to clear I'll put a little example below.
Data:
Robbery: 4 on campus, 5 off campus, 6 in city, 0 in apartments Rape: 0 on cmpus, 3 off campus, 4 in city, 0 in apartments murder: 0 on campus 0 off campus, o in city, 0 in apartments
I have a database that holds hardware data. It's working fine, but there's a slight itch I'd like to scratch and I'm not sure how.
Very simply, I have a table listing printers. I have a search form with combo boxes called 'cboRoom' and 'cboDepartment'. The room and department fields in the printers table are lookups to a room table and a departments table respectivley.
The search form works fine by using the combo boxes to select a room and/or department, click search, and a query is run using the combo box selections as parameters. The query is also made to show all records if the combo boxes contain null. A form is then displayed with the query results.
Say for example, we have a room called B24. If B24 is selected in the combo box and the query run, I want a popup to appear that says 'No data with these search parameters' if there are no records containing 'B24'.
The search button (which is actually a label for design reasons) on the search form currently does nothing more than this;
Private Sub lblSearch_Click() DoCmd.OpenForm "frmPrinters", acNormal DoCmd.Close acForm, "frmPrinterSearch" End Sub
'frmPrinters' is obviously using the query (qryPrinterSearch) as its recordsource. Obviously, the popup needs to appear as soon as the query has been run, but I'm not sure what code to use or where to put it...
I know I need some sort of (pseudo)
If frmPrinters.cboRooms Is Null MsgBox "No Data" Close frmPrinters Open frmPrinterSearch End If
Something like that. But obviously I need to do it for both cboRooms and cboDepartments, after the form has attempted to populate itself with data from the query (otherwise it return null values anyway I guess).
Any help with the code and where to put it much appreciated.
A form i have gains its records from a query. I know that the number of records found is displayed down the bottom, but is it possible to have a text box displaying this, so i can choose where on the form i have it?
I am using a query to search for records and I'd like there to be a message box that pops up on the search page if there are no records found (so the query is empty). I'm guessing there is a simple solution since I think I just need an "If" statement checking to see if a field in the query is null or not. However, I'm not familiar with Access code and what I've tried so far does not work. Any help is greatly appreciated! p.s. I am using Microsoft Access 1997...old school...
The following is code to open a form and records with a specific date as input by the user:
Private Sub cmdDisplayCovers_Click() On Error GoTo Err_cmdDisplayCovers_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmInventory" stLinkCriteria = "[tblCovers].[Date] = [Forms]![frmCoversByDate]![txtDate]" DoCmd.OpenForm stDocName, , , stLinkCriteria etc. etc.
generate a message to user if no records match the input and then return to the input form. Currently, the form opens even with no records.
Table: Relationship PK: RelationshipID int (Indexed No Dup) FK: ContactID int (Indexed No Dup)
Table: Contact PK: ContactID int (Indexed No Dup) FK: RelationshipID int (Indexed Dup Allowed)
I also have following Local vars: @Contact1 int @Contact2 int
How do I create an UPDATE statement that will read RelationshipID in Relationship where Relationship.ContactID=@Contact1 and use it as the value to update the Contact.RelationshipID for all records in Contact where Contact.ContactID = @Contact1 or @Contact2
Hope this makes sense?
Also please let me know if I should post this in the SQL area instead.
Code: Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst "[OwnerID] = '" & Me![lstUsers] & "'" Me.Bookmark = rs.Bookmark <---- error is here for the datatype mismatch or No record found
I have a query using Access 2003 accessing invoice information from a table linked from our point of sale system. The query runs perfectly displaying all info including dates if there are no specific dates indicated in the criteria. If I select a date in the criteria field I get the message "the search key was not found in any record". I used Access 97 for years and had no problem with this query. I recently changed to Access 2003 because we upgraded all computers to Windows 7. Is the search criteria format different in 2003 vs 97?
I am trying to provide the user a custom search feature. They want to enter a keyword or phrase and search 3 memo fields and filter the form base on the records found. they also want to be able to search the whole phrase or any part of the phrase.
I have a like expression for any part of the phrase but I when I set it up for whole phrase it doesn't work. Even if I run a simple query and use
For example: There's an acronym the user is looking for : ACA
If I set my query up like this: [field1] like "*ACA*" or [field2] like "*ACA*" or [field3] like "*ACA*"
it not only finds records with that acronym but it also finds records where that combination is found in a word, for instance vacate.
Hoping someone can help me with this DELETE query. I have a Main table that's being updated by a Temp table that's an exact copy of the Main table but with a subset of records.
1) Insert records from Temp table NOT found in the Main table - this query I have worked out below - not tested, but the results look correct.
Need Help Here... 2) Delete Records from the Main that are not found in Temp table with an exception...only DELETE records where certain key fields are matching. i.e. If S.CAD_NAME, lngStoreNumber are a match to what's in the Main table. While Temp table: lngStoreNumber - CAD_NAME - lngcomponentSerial 1 - "CHK" - a 1 - "STK" - a 2 - "CHK" - a
Main table lngStoreNumber - CAD_NAME - lngcomponentSerial 1 - "CHK" - a - LEAVE (EXISTS In Both Tables) 1 - "CHK" - b - DELETE (lngStoreNumber & CAD_NAME composite Found /lngcomponentSerial NOT Found in Temp) 1 - "STK" - a - LEAVE (EXISTS In Both Tables) 1 - "RMM" - a - LEAVE (lngStoreNumber & CAD_NAME NOT Found in Temp) 2 - "STK" - a - LEAVE (lngStoreNumber & CAD_NAME NOT Found in Temp) 2 - "CHK" - b - DELETE (lngStoreNumber & CAD_NAME composite Found/lngcomponentSerial NOT Found in Temp) 3 - "CHK" - a - LEAVE (lngStoreNumber = 3 Not in Temp table Subset)
Rule: Only delete the records for a particular CAD_NAME and lngStoreNumber from the Main table leaving all other CAD_NAME/lngStoreNumbers.
I'm running these updates in batches of lngStoreNumber. So the Temp table will only contain subsets of what's to be deleted from the Main table thus the need to link on the key fields only NOT to delete a Subset of lngStoreNumber/CAD_NAME. I think I've tried every possible query that doesn't work.
Here is query #1 to insert records missing from the Main table that exist in the Temp table. I think what I need is a variation of this??? SELECT D.* FROM Main AS S RIGHT JOIN Temp AS D ON (S.CAD_NAME=D.CAD_NAME) AND (S.lngcomponentSerial=D.lngcomponentSerial) AND (S.lngStoreNumber=D.lngStoreNumber) WHERE S.lngcomponentSerial is null AND S.CAD_NAME is null AND S.lngStoreNumber is null;
In my simple database (attached), I need to mass duplicate Tasks and their Notes.
I have three tables: tbTasks (PK: Task_ID), tbNotes (PK: Note_ID), jtbTaskNotes (FKs: Task_ID and Note_ID). jtbTaskNotes is my many-to-many junction table that ties Tasks to Notes.
The main form (fmTasks), bound to tbTasks, has a subform (sbfm_TaskNotes) that displays notes associated with each Task. On themain form,you select which Tasks you want duplicated via a checkbox. The append query (quCopyTasks) will duplicate all tasks that have the checkbox checked. All good there. However, I can't figure out how to also duplicate each task's Notes.
I found Allen Browne's solution [URL] ....., but that only handles duplication of one record at a time, whereas I need to duplicate many records at a time (sometimes 10+ records). How do I go about duplicating multiple Tasks and their associated Notes?
Before you ask "why are you duplicating records?": There are times when tasks need to be re-accomplished and therefore need to have a new record. It's easier to duplicate records than it is to hand-jam everything again.
I have a database that is used to create Quotations. After all of the information is entered the queries that hold the calculations must be run. I have lots of calculated that rely on other calculated fields. When I need to Sum all of the calculated fields in one field I must create a new query. I currently have a QuotationID, PartID, and MetalID all linked together. The first of the calculations are done per Metal, and these are working fine. I run into a problem when the calculations need to be done by part. My Queries are creating a record for every Metal and this is throwing all of my numbers off.
I have a query that will draw down student details who have completed a course in a given month (May for example), i would like to use this data to identify those learners who are not enrolled on a course in the next Month (June for example). There is no field that denotes whether a student has left only that a course assosciated with their ID has a completion date within that Month. There are approx 250 records.
In my head it should work something like this
1) Identify all learners who finsihed a course in May (Identify learner ID, must have a course end date in that month)
2)Cross reference these against all those who started a course in June and identify the students that have completed in May but did not start a course in June.
Is it possible to store all those who completed (May) in a table/query and cross reference those who started in June and identify of the May completions who did not start in June?
mY Access database short cut is giving error...like Access datbase fiel could not be find on specified location. When i open the database rather than from shortcut giving the same error.
But when i go into server and open there it works fine.
I am trying to import a table from a notepad doc and i get an error message " The search key was not found" Please can someone explain to me what this is about and if there is a solution for it. Does this have anything to do with size of the database beign too large?
I have a simple one table database which I made a few weeks ago to print letters. All was working ok until I hit record #14, I enter the client details and when I quit the database an error message appears saying 'The search key was not found in any record.' with an option to hit OK or Help buttons. If I hit OK another message box appears saying 'You can't save this record at this time.' and stating that Access has encountered an error & if I close the database I will loose any changes etc...
If I do close it, most of the data I have entered turns to chinese characters & the rest doesn't even ressemble anything close to what I have inputted. Strangely enough records #15 & 16 work ok and the error only seems to be when I alter the data in the postcode field on record #14
Hi. I have two tables, both with load of info. I need to run a query, that checks data in table1 against data in table2. If it is in table two, then moves on. If it is NOT, then shows the results to me. So that i can see which ones were not there. how do i go about that.