Abbreviate values in report field in Access - ms-access

I have a 2010 Access database that tracks volunteers for a charity group.
One of the columns in the VOLUNTEER table is called AVAILABILITY and the possible values are "seasonal" and "year-round".
I have created a report that lists out all the volunteer information, and it includes this column. The only problem I have is that I'd like to have the report abbreviate the values. Ideally "S" for seasonal and "YR" for year round in order to save space on the report. Is this possible?

Yes, of course. You can either do it in a query and base the report on that or in the report itself:
SELECT IIF([AVAILABILITY] = "Seasonal","S","Yr") As Avail
FROM MyTable
If you wish to set the control in your report, make sure to rename it to something other than Availability, say txtAvailability:
= IIF([AVAILABILITY] = "Seasonal","S","Yr")

You could use an IIF function, but this only allows for two availability options. To allow for more in the future I would create a second table to look-up the abbreviations that are going to be displayed in your report.
Copy and paste this into the SQL Editor in Access to create such a table:
SELECT "Seasonal" AS Availability, "S" AS Abbreviation INTO tblAvailabilityOptions;
You are then going to create a query that your report will be based on that combines your main table with the new table you just created, joining on the "Availability" column:
SELECT tblMain.ID, tblMain.Volunteer, tblMain.Availability, tblAvailabilityOptions.Abbreviation
FROM tblMain INNER JOIN tblAvailabilityOptions ON tblMain.Availability = tblAvailabilityOptions.Availability;
If you know how to use the combobox lookup feature on your main table, this will be even easier.

Related

Create a "Template" SQL in SSRS

I have a set of SQL queries built for SSRS. I am building
reports for multiple customers and my queries apply to all of them
- except I have to replace the company name in the WHERE clause.
Can SSRS create a "template" SQL query and automatically replace
the company name and apply according to the appropriate company
name?
A good way to achieve this is with an SSRS parameter. If you right click the parameters and add one I call mine "client" but you can use company name etc if you prefer.
If you only have a few options for companies you can add them in manually as "available values" but a good option if you have lots of posilbilities is to create a dataset (paramset) from new query that is simply
SELECT
distinct
[Company Name]
From {your table}
Then you can use the "get values from a query" option to automatically fill the parameter drop down box with all the potential options.
After that all you need to do is add
Where [Company Name] = (#Client) or #{whatever your parameter is called}
to your query. When you run the report you should get a dropdown box with all the company names in it and from there you can pick one and it should apply the filter to your data automatically. That way you can build one report and run it for as many companies as you like.

Ms Access, make one table get data from another table in real time

So, i have 2 tables, let's say : Customers and Activity. Customers containing only customers and activity containing customers but also other pieces of information.
I have a form to write data in the Customers table.
What i need is the Activity table to auto-update itself each time I write an entry in the Customers table.
Is it possible to create a relationship between the two tables to do that? Or should I write something at the end of the code I use for the form?
Is it possible for instance to create a function that i call at the end of the code i use for the form?
Thanks.
If you're wanting to automatically update, independently of any form, a table based on changes made to another table, I would recommend a data macro which is new to MS Access 2010. They're pretty cool and are similar to triggers in enterprise level relational database management systems.
Open your Activity table. Under table tools create a named macro called NewRecord. Create a parameter called prmCustomer. Your macro could look like this:
Create a Record In Activity
Alias
SetField
Name Customer
Value = [prmCustomer]
Then open your Customer table. Under table tools create an After Insert Event. Your event could look like this:
RunDataMacro
Macro Name Activity.NewRecord
Parameters
prmCustomer = CustomerID
You'll have to do some playing around since you haven't given much info, but that's the gist of it.

Access Form Field Logic

I'm trying to make access conditionally only show rows that meet a certain condition, allow me to give you some background info before I proceed :
I've created an Access form and linked it to a test DB on my machine. The particular table I am interested in contains the following (important) rows :
ID , Office, Name, SecurityNumber
The thing is, ID is not unique. There are two Office locations, and each Office has it's own set of unique ID numbers. This means that ID 10 here and there may or may not be the same person. (this data comes out of a legacy security system we're not looking to change yet, so I cannot change it)
But ID -is- unique to each Office.
SO! I created an Access form with TABS! Two tabs, one for each office. What I am trying to achieve now is :
Have the ID/Name/SecurityNumber fields for each tab populate with only rows that match it's particular 'Office' value.
Thank you for reading and thank you for helping! :D
If you want the data for the office locations presented in separate tab page controls, you could use subforms on the pages which differ only in the WHERE clause of the queries used as their record sources. So for the Office1 subform, the query could be:
SELECT ID, Office, [Name], SecurityNumber
FROM YourTable
WHERE Office = 'Office1'
ORDER BY [Name];
Then for Office2, the query would be the same except for the WHERE clause:
WHERE Office = 'Office2'
As I understand your question, that approach would do what you're asking for.
However, that's not really the easy "Access way" to do it. Instead consider a combo box control to allow your users to choose which office they want to view. In the code for the combo's after update event, either modify the SELECT statement used as the form's record source or create a filter expression an apply it.
Also, since you're pulling the form's data from SQL Server, consider whether you want your form to load every record for the selected office location. It may not be much concern if you have only a few to moderate number of rows for each location, but if you'll be dealing with multiple thousands of rows it could be. In general, you should try to avoid pulling copious amounts of data across the wire; pull sparingly instead ... only what you need for the immediate task at hand.

MS Access Report showing the id of the combobox and not the bound name column

The company I work for have an access database that is linked to a sql server table. The database is on a shared network location so it is used by lots of people in the company (with the annoying problem that only one person can use it at a time).
There are several forms that are used as a front end for the data and on one particular form there are combo boxes that are linked to other tables.
When a report is generated on the form the ID of the combobox is on the form (a GUID) and not the bound item of the combobox.
How can I get the bound items to appear on the form itself? The solution needs to be easy to do or something i can produce that can be regenerated as it's used by non technical people.
In order to make the database usable by many, simply give each user a copy of the front-end.
Forms should almost never be used for reports, the best thing to do is to build a query (the query design window will help) that references each of the relevant tables, for example, if the combobox contained a reference to person type and you might build a query like this for your report:
SELECT a.ID, a.SName, a.MainAddress, c.PersonType
FROM Addresses a
INNER JOIN PersonTypes c ''Or LEFT JOIN if data is missing
ON a.PersonTypeKey = c.PersonTypeKey
If this is not possible, perhaps you could explain in more detail exactly how the report is generated from the form.

Multiple Queries in One Report - MS Access

To keep this simple, lets say I have two tables.
The first is called Employees. It contains an id field and an employee_name field.
The second is called Pay. It contains an id field, an employee_id field and an amount field.
Now, I want to run a report on Pay that shows me how much each employee got paid by showing me only the Employee.employee_name and the Pay.amount.
Obviously, I'm going to have to take the employee_id field from the Pay table and match it up with the the id field from Employees, but I have no idea how to do that.
I know a little VBA and am pretty knowledgeable with SQL, but MS Access has me so confused I'm about to kill myself. I hate Access so much, I want to take it outside behind the middle school and get it dead.
This seems like a relatively easy problem, so someone has to know how to do this. Any help would be hugely appreciated.
You are looking for a query like this
SELECT Employees.Id,
Employees.employee_name,
Sum(Pay.amount) AS SumOfamount
FROM Pay INNER JOIN
Employees ON Pay.employee_id = Employees.Id
GROUP BY Employees.Id,
Employees.employee_name;
If you wish to make this as part of a list box, you can either save the sql as a query and set the Listbox property under the Data Tab called RowSource to the Saved Query Name, or you can set the sql string as the RowSource.
Remember to have a look at the Properties called Column Count ( something like 0;3;3 0 being to hide the first column ) and Column Heads (to include column headers, default NO )
If you widh to craete a Report using the data, you can go about this the same way ( Saved Query or Use the Sql String ). The Query/Sql String can be set in the Data Tab in the Record Source property. Now you can add the fields to the report from the Existing Fields window.