Queries :: Show All Names In First Column And Insert Zero Where No Record Exists
Aug 27, 2014
I'm tracking the holiday entitlement of a team of people. I use a query to work out how much unbooked holiday they have to take.
My problem is where I'm scheduling next year my query returns the names of those who have booked a holiday and their remaining entitelement. That's as it should be. However if someone hasn't yet booked any holidays then it simply doesn't display their record. I would like it to treat that record as zero and show the remaining entitlement as a full years entitlement.
Here's the SQL
SELECT Employees.Trainer_Name, Sum([2015 Holiday].[2015 Days]) AS [SumOf2015 Days], Employees.Holiday_Days, [Employees]![Holiday_Days]-[SumOf2015 Days] AS 2015
FROM [2015 Holiday] INNER JOIN Employees ON [2015 Holiday].Trainer_Name = Employees.Trainer_Name
GROUP BY Employees.Trainer_Name, Employees.Holiday_Days;
The problem here is that the Sum of 2015 holiday is Null
Select Year,Type,Count(*) from Table group by Year,Type;
I am running the above query to create a bargraph:
Result of my query: Year Type Count ---- ----- ------ OCt-10 Type1 5 Apr-11 Type 4 4
Expected graph:
Y axis Counts X axis Year and then Type together
Two bars in total : One bar for Oct-2010,Type 1 showing a count of 5 One bar for Apr-2011,Type 4 showing a count of 4
Is it possible to show Year as well as the Type values as labels in X axis in a barchart. I know it can be done with pivot charts but I dont know how to create it as a report with pivot barchart .
I have 2 or 3 Queries which are run specifically export data to an Excel file required by external agencies.The queries contain column headings, required by the agencies, which are not derived from Table fields. Obviosly, no record data is produced for these columns.When the queries are run, the dreaded 'Enter Parameter Value' message appears for each to the additional column headings.
The following is a copy of the SQL Code for one such Query;
SELECT DISTINCTROW [Name1] AS Title, [Mail List].[First Name], [Mail List].Surname, [Mail List].[Address 1], [Mail List].PostCode, [Name2] AS [Aggregated Donations], [Name3] AS [Sponsored Event], [Mail List].SubDate, Sum([Mail List].[ Recd]) AS [SumOf Recd] FROM [Mail List] GROUP BY [Name1], [Mail List].[First Name], [Mail List].Surname, [Mail List].[Address 1], [Mail List].PostCode, [Name2], [Name3], [Mail List].SubDate, [Mail List].[Gift Aid] HAVING ((([Mail List].SubDate)>#4/4/2014# And ([Mail List].SubDate)<#4/6/2015#) AND (([Mail List].[Gift Aid])=True));
Is there not some way in which these columns can be defined in Property Sheet such that this error message is prevented?
I am trying to create a rolling twelve month query that will total the months across. I set the query up so that it is a rolling twelve month, but I am having difficulty getting it to list the months across. I would like it to take the first month, list it as a column and show the totals according and the same with each month after. Here is the query that I currently have:
SELECT WIPHistoryTbl.WIP_PART_NUM, WIPHistoryTbl.WIP_MONTH, WIPHistoryTbl.WIP_YEAR, SpinsMonthEndTbl.WEEKS_IN_MONTH, WIPHistoryTbl.WIP_AMOUNT, IIf(Count(Switch([WIP_MONTH_NUM]='06',1))=1,Sum([WIP_AMOUNT]),' ') AS JUNE_TOTALS FROM SpinsMonthEndTbl INNER JOIN WIPHistoryTbl ON (SpinsMonthEndTbl.SPINS_YEAR = WIPHistoryTbl.WIP_YEAR) AND (SpinsMonthEndTbl.ACCT_MONTH = WIPHistoryTbl.WIP_MONTH_NUM) GROUP BY WIPHistoryTbl.WIP_PART_NUM, WIPHistoryTbl.WIP_MONTH, WIPHistoryTbl.WIP_YEAR, SpinsMonthEndTbl.WEEKS_IN_MONTH, WIPHistoryTbl.WIP_AMOUNT, WIPHistoryTbl.WIP_MONTH_NUM, SpinsMonthEndTbl.BEG_DATE, SpinsMonthEndTbl.END_DATE HAVING (((SpinsMonthEndTbl.BEG_DATE) Between (Now()-365) And (Now()))) ORDER BY WIPHistoryTbl.WIP_YEAR, WIPHistoryTbl.WIP_MONTH_NUM;
I would really like it if the query could look at the BEG_DATE, select the corresponding ACCT_MONTH and show it as the column header.
These are what I would like my results to look like: PART_NUM | 06_TOTALS | 07_TOTALS | 08_TOTALS . . . . . . . . . 123456789 | 10 | 5 | 15 .
I have a spreadsheet which contains data exported from another system (which I have no control over). I'm using this spreadsheet as a linked table in my database.
The problem I am having is that I can't guarantee that when the spreadsheet is updated, it will contain the same column headings as it did the last time...
The spreadsheet contains a list of temps, with a summary of info off their submitted timesheets. So the column headings (as well as WorkerName, TimesheetDate, etc) may be "Standard Hour", "Overtime Hour", "Over 12 hrs Hour", "Standard Day", "Overtime Day", etc - for each type there will be a Pay Rate and a number of units (hours or days) claimed. The columns only appear if 'someone' in the spreadsheet has claimed something under that heading this week.
What I need to do is to produce a report which gives a summary by person and week of the number of hours claimed and the total charge. I've done that - that part was easy The part I'm struggling with, is how to take the column headings and turn those into descriptors for each charge type... in otherwords, to go from the sample 'timesheet' below to the sample 'ByType' ?
... when I don't know which columns will be present each week?
At the moment I'm using a union query to pull out the info I need, but if the column headings change then I know it will stop working...
sample of my union query... I currently have 8 different sets of bill rate and charge rate, this just does the first couple...
Code: SELECT qryTimesheetBaseData.[Time Sheet Start Date], qryTimesheetBaseData.[Time Sheet End Date], qryTimesheetBaseData.[Cost Centre], qryTimesheetBaseData.Worker, "Standard" AS RateType, "Hourly" AS RateCategory, qryTimesheetBaseData.[Bill Rate (ST/Hr)] AS Rate, qryTimesheetBaseData.[Time Sheet Billable Hours (ST/Hr)] AS Billable, qryTimesheetBaseData.[Time sheet Status] AS Status
Code: strSQL = "INSERT INTO tblDepartments (Department) VALUES(txtnewdept)"
To insert new departments into a table, however id like it to check to see if a department name exists in tbldepartments.department to prevent duplicates being added?
The problem I have is, that I need to insert an apointment into de database but first I need to verify if there is a record or an apointment in that room that day the same hour, if that is so send a msgbox saying an apointment already exist in that room this day at this hour.
i tried using dlookup but it only works in one record using just one criteria
How to take the results of query and copy them to a column in a table?
I am using sharepoint and ms access together, and Sharpoint in this instance will not reference the result of the query. I can only use table fields with Sharepoint...major pain....
Example, I need riders name, weight and height from the column in ALL INfo query to automatically fill the column table in ALL Info
I want to automate a query so when the user views it they see only the columns that have data. Columns that do not have data are not there.I am using MS 2007
My Access tool is setup to import data into tables and then the user views the data imported. However, if their's no data (and no column to import) I want the query report to not include the column.
I have created a query/report that meets all necessary criteria except that it contains multiple TYPEs per employee. This isn’t an issue unless one of the TYPEs is ‘W’. As TYPE ‘W’ supersedes all other TYPEs, any others that meet the other criteria should no longer be reflected in the query/report.
Came across a problem and wanted to see if anyone else has seen this or knows the cause.
I am working in Access 2003.
I have two tables stored in a backend. One table updates the other. The database I inherited was doing this via the copyobject. I wanted to use a del query to delete recs in target table then an append query to update from source table to target table.
Both tables have data fields named in the following format: 01/2007, 02/2007, etc. If I write a select query and save it, it works fine. However, if I write an Append query, the INSERT clause chops off the leading 0 of all fields upon save which causes the query to not work correctly. Anyone know why this happens?
I have a sub table that acts as a revision history for the items in my main table. I've just finished uploading all the records into the main table and now I want to insert one record into the subtable for each record in the main table to start the history with the record creation.
The sub table looks like this:
tblRevisions - RevID (auto Number / primary Key) - RevDate (date of revision) - RevName (Who made the revision) - RevDesc (What revision was made) - RevAuthorized (Who authorized the revision) - RevLabel (Foreign key to the primary table)
The info I want to insert is:
RevID - Auto Number RevDate - 11/27/2013 RevName - 3 RevDesc - "Added Label to database" RevAuthorized - 1 RevLabel - (One for each record ID in tblLabels)
I suspect that I want to start with an insert into statement, something along the lines of:
Code:
Insert into tblRevisions (Revdate, RevName, RevDesc, RevAuthorized, RevLabel) Values ("11/27/2013",3,"Added label to database", 1, ?)
I'm not sure how to indicate that there should be one label for each Record in tblLabels or that revLabel value should match the ID from tblLabels though.
I am trying to create an ASP script that I can use to take the column names out of my access database, and then take out the data. I have a select statment like this:
Code: <%Set conn = Server.CreateObject("ADODB.Connection")conn.open "source","",""SQL_query = "SELECT * FROM table"Set RS = conn.Execute(SQL_query)%><%WHILE NOT RS.EOF%><%=RS("field")%><%RS.MoveNext WEND%>
I would just like to make it so the above script just takes out each column header from my database table, and instead of the <%=RS("field") it shows the current column name.
I have a project of migrating our Access data to Oracle. One of the pre-reqs the boss wants is to uppercase all of the column names (Field name) for all of the tables. I want to avoid manually going in all the tables and changing the case of the columns because there is like 300 tables where dealing with. I was wondering if in Access..is there an efficient way of converting my column names to upper case via script? VBA or Macro?
I am using Access 2007 and would like to know how to copy column names from one table to another. I am importing data from excel and the column names come out as 'Field 1', 'Field 2', etc. I went through the trouble of manually renaming the column names of one of the tables (22 columns in all). I will be importing/creating 55 new access tables and don't want to have to manually rename all of these columns. All of the columns in all of the tables will be exactly the same, so I was hoping that after I did this once, I could copy the column names to the other 54 tables.
How do you display the names of field for a table in a combo box. I know how to do it in mySQL "DESCRIBE employee_data", is there a SQL command in access to do this?
I used the code below to check the empty fields in the form and populate it in a message
Code: Private Sub Form_BeforeUpdate(Cancel As Integer) Dim ctr As Control Dim strMsg As String 'Loop through every control on the form For Each ctr In Me.Controls
[code].....
I want the message to show the captions of controls instead of its names