I currently have a database in MS Access that I need to update the way we generate form letters.
We use a query I made 10 years ago to generate certificate of attendance letters.
SELECT doctors.address, seminar_title, seminar_date, first_name, last_name
FROM doctors, seminars, registrations
WHERE seminars.seminar_id=[Seminar] AND registrations.seminar_id=seminars.seminar_id AND
registrations.dr_id=doctors.dr_id
ORDER BY doctors.last_name;
The result is a set of letters for whatever seminar ID you enter. Each letter representing an individual registration by a doctor.
The issue now is that we have an additional table (Licenses), and I need each letter to display 1 to 5 licenses that a doctor might have.
The fields in the Licenses table are: license_ID, doctor_id, license_type, state, and license_number.
I can display one license, but getting a varying amount of license numbers and states to display, each matched on a letter to its licensee, has been beyond what I know how to do so far.
Any input is appreciated.
You'll want to create a subreport listing all of the licenses for the doctor the letter is addressed to. First you will need a table linking doctors to the licenses they have (e.g. "doctor_licenses"), with the fields dr_id and license_id. Add doctors.dr_id to your query above so it is part of the recordsource for your main report. Then create a second report to display the licenses for each doctor. The recordsource for your second report will be something like
SELECT dr_id,
license_type
FROM doctor_licenses
INNER JOIN licenses
ON doctor_licenses.license_id = licenses.license_id
Add the second report to your main report as a subreport. Link the subreport to your the main report by setting its "Link Master Fields" and "Link Child Fields" properties both to dr_id. More info on subreports and how to create and use them here:
https://support.microsoft.com/en-us/office/create-and-use-subreports-816f987a-4615-4058-8f20-ce817093bb33
EDIT because I can't comment on your original post, you'll still need to use a subreport to list doctor licenses as there is a one-to-many relationship between doctor and licenses (one doctor can have one or more licenses). If you're trying to add the list of licenses as a comma delimited list or something similar to your report you'll have to utilize a more complicated approach. Please look at the subreport solution and if that doesn't do what you need please be more specific about your requirements.
Related
I have a timecard file that list the daily hours for each employee. I have figured out, using a query, how to get the total number of hours but I also need the total number of employees. I have searched here and on other places and tried just about everything and nothing works. I am sure it is something pretty simple but I just cannot seem to get the total number of employees. Any help will be greatly appreciated.
The main file is called Timecards and I link to a file call Employees using the field employee number to get the employee name. There are other fields in Timecards namely "Job No", "Job Description" and "Type of Hours"( such as regular and overtime) that I wanted on the summary report but I did not realize that a employee could have two entries in those fields. So that is why I could not get the total employees to come out right when using those fields.
I was finally able to create a query and print a report with the total employees using fields that only appear once in the Timecards file. So unless someone knows how to count total lines is a report I will stick with the report I have that works.
I agree with Vladimir, it helps to post what you expect to see and what kind of tables you are working with. However, I have been in the same situation. Maybe this is a good starting point in SQL
SELECT COUNT(*) AS TotalNumberEmployees FROM TheTableShowingEmployees;
Posting a question with:
A problem statement
A list of expected results
Sample Code tried
Table structures involved (Including relevant fields, data types, and tableNames)
Will get you better results. Show your work, we'll show you ours!
Given limited information so far this is the best I can come up with
I use a left join incase some of the employees haven't reported hours yet and you want all employees.
I use coalesce to change null hours to 0.
I assume that Employees Table exists and it joins to timecard on Employee_no.
I assume firstName and LastName are in the
employeetable
.
SELECT coalesce(Sum(T.hours),0) AS SumOfhours, E.FirstName, E.LastName
FROM Employees E
LEFT JOIN Timecards T
on T.Employee_no = E.Employee_no
GROUP BY E.FirstName, E.Last_name
Also note you can edit your question don't comment on it; it makes it difficult to follow.. and last but not least .... Welcome to SO!
Well after much searching and testing I finally found a post from 2009 that took care of my problem.
`If you want to count groups, you might need to add a running sum text box in
the group header. For instance, if your report contains orders and order
details but you want to count the number of unique orders, you can't use a
text box in the report footer with a control source like:
=Count(OrderID)
This expression will count orders and details.
You can add a text box in the Order header:
Name: txtOrderCount
Control Source: =1
Running Sum: Over All
Visible: No
Then add a text box in the Report Footer section:
Control Source: =txtOrderCount
Duane Hookom
Microsoft Access MVP`
Thanks for all the help.
I'm working on an Access Database for everyday use in a team of 15.
Everyday the team will input 10-15 Names into this database and I need the database to see if the name already exists.
Easy enough, however some names don't match exactly.
For example the team will enter in this format into ONE field:
Lastname, Firstname
But the existing records that are imported from an automated report may have an initial at the end like:
Lastname, Firstname M.
This is enough to make the difference when using this query:
SELECT All_test.[Name], All_test.[EjSupervisor], All_test.[ID], All_test.[Department], All_test.[Location], All_test.[EbEmpNumber], All_test.[Date Manager E-mailed]
FROM All_test
WHERE (((All_test.[Name]) In (SELECT [Name] FROM [All_test] As Tmp
GROUP BY [Name],[EjSupervisor]
HAVING Count(*)>1 And [EjSupervisor] = [All_test].[EjSupervisor]))) and len(rtrim(Name) - 3)
Completely open to suggestions here.
"Everyday the team will input 10-15 Names into this database and I need the database to see if the name already exists."
For data input, give the users a form with a combo box which presents the existing names. They can then easily choose from among those names.
When they input a name which does not exist, Use NotInList Event to Add a Record to Combo Box.
I have a tricky thing I'm trying to get working
I have a table that contains events, and 10 fields populated with ID Numbers of employees who attended, and a comment box for each one. I tried to create a query that uses a combo-box with the ID Number to Search for the events they attended, and display them in a form cleanly (IE without displaying other peoples, or having a large number of text boxes everywhere). I got it partially working but I could not figure out how to go any farther. I can't figure out how to separate out the fields by the people. I was toying with the idea of having the event listed say 10 times with one person per record but that would cause alota bloat.
Any ideas how to do this? Different formats/other approaches would be great as well.
Thanks guys.
I would split the tables... have one that contains the event, with an eventID field as an AutoNumber. Then have another table called Attendance with three fields: eventID containing the ID of the event, employeeID, and Comment for the comment. This would then even allow you to create another table containing more info about the employee like first name and last name for use in reports.
Please I would like to know ho to separate customers in category, since we have two type of customers, the first group should only appear in crm->customers only and vice versa to avoid having a huge list of customers when searching.
My first attempt is to add a tag to different customers to separate them, for example the crm customers have the tag name Mass mailing is it correct to achieve this with tags ?? and my second question how to set default search keyword for example if I click on sales -> customers how to set the default value of search box to for example crmOnly tag thanks.
you can use "domain" where ever you want to have a such a separation.
I have a spreadsheet in excel with three headers:
Project Name
The name of a project i'm working on.
Requested Role
The job title/profession of the project employee. (example: mechanic, manager, engineer)
Name
The name of the employee.
When i click on the Person's name i want another page or tab (specific to this person) to appear showing details about them such as their name, job title, how long they worked, what project they are doing... etc. (similar to a Facebook profile)
When i click on the project name i want another page or tab (specific to this project) to appear showing details about it such as the requirements, the deadline, who is currently working on it... etc.
Furthermore, i would like to set up two levels of access:
Managers:
People who can add new information but not change or delete existing information
(write-only permissions)
Administrators:
People who can have full access to all information.
All highest level of access.
I don't know how i would go about displaying and/or organizing so much information in a vb.net application. if anyone could provide some suggestions as to some possible layouts of the GUI it would be greatly appreciated!
Additional Details:
For the specific pages i was thinking of using the tab control but i want it so that i can search through the list of projects or names, select one, and then it brings up the page about it.
The levels of access is the least of my worries... although it is still a worry.
You don't want to store that information in an excel spreadsheet, a database is much, much better. For what you've described here I'm going to assume that you have Projects and Employees, and that multiple Employees can work on a project. You'll need a few tables then:
Project
ProjectSeq 'Int - unique sequence for this project record
Name 'String - name of project
Descr 'String - description of project
... 'Various - other fields as needed
Employee
EmployeeSeq 'Int - unique sequence for this employee record
Name 'String - Name of employee
Title 'String - Job title of this employee
IsManager 'Boolean - Is this employee a manager?
IsAdmin 'Boolean - Is this employee an administrator?
... 'Various - other fields as needed
ProjEmpl
ProjEmplSeq 'Int - unique sequence for this project-employee record
ProjSeq 'Int - link to project record
EmployeeSeq 'Int - link to employee record
... 'Various - other fields that apply to this project-employee combination
Once you have your tables all set up and populated with data, you'll want to read the data and transfer it to your .NET application. There are a few ways of doing this, you'll have to decide which works best for your needs. I'm a big fan of DataSets, they always work nicely.
To fill the grid, you'll need to use a sql statement that fills a datatable from the three tables (I'm using notepad as my IDE, so this may not be exact):
SELECT pe.*, p.Name as ProjName, e.Name as EmplName, e.Title
FROM ProjEmpl pe, Project p, Employee e
WHERE p.ProjectSeq = pe.ProjectSeq AND
e.EmployeeSeq = pe.EmployeeSeq
To display the data to the end user, you would use a DataGridView control. Set the datagrid.DataSource to use the datatable you just populated and the data should show up.
To display the related Employee & Project information, I'd use a tab control underneath the datagrid. One tab for Project, and one tab for Employee. Use individual controls for each field in the table. When the user changes rows in the datagrid, load the related Project and Employee information for that row into two datatables and populate the controls from that.
Lastly, to set permissions on the program you'll need to have the employee log onto the application. Once they've logged on you can look them up in the Employee table, find out if they are a manager or an administrator, and set the permissions accordingly.