comments inline.
Tec92407 said:
Thanks Tina
I followed your suggestion and it worked well.
In addition, I created a new page (tab) on the assets form and used the new
Asset Assignments table for the subform. So I can click an "Assignments" tab
to assign an employee.
I have a couple of other questions.
1. At the moment, I only show the Employee ID, DateAssigned and DateReturned
fields on my Assignments subform. I'd also like to add the employee
DepartmentID as a view only field. I'm thinking I need to add a DepartmentID
foreign Key in the Employees table and set a relationship between employees
and department tables.
Is this correct?
yes. keep in mind that departments are related to employees, not to assets
or asset assignments. to *show* an employee's department in the
AssetAssignments subform, use a query or SQL statement as the RowSource of
the EmployeeID combo box in the subform. in the query/SQL, link tblEmployees
to tblDepartments on the primary/foreign fields pair. add the DepartmentName
field to the query grid. make sure you increase the combo box's ColumnCount
property by 1, and add the following to the *end* of the ColumnWidth
property's value, as
; 0"
now the combo box includes a column containing the employee's department
name, but the data doesn't show in the droplist. however, the column's data
is available to you programmatically in the subform. so add an unbound
textbox to the subform, i'll call it txtDepartment, and set its'
ControlSource to
=[ComboboxName].[Column](n)
replace "n" with the index number of the DepartmentName column. combo box
columns have a zero-based index, so the first column (counting
left-to-right) is zero (0), the second column is (1), the third column is
(2) , etc.
2. There is an Employee form with a subform that is accessed with a Tab
labeled
"Assets assigned to this Employee". It shows three fields, asset
description, barcode number and serial number. It doesn't work correctly
anymore since making the new change. Am I correct in thinking that I will
have to change this form to reflect a select query? I want to show more
fields than just these three.
well, i haven't looked at the template db again. but you're correct that
once you remove a field from a table, you also have to remove the field from
queries, forms and reports. and remove references to the field from VBA
code, macros and expressions. frankly, it's a pain in the butt to go through
a database and track down all that, but that goes with the territory of
modifying somebody else's database (or even your own db, after it's
completely built "one way".) on the plus side, you usually get an pretty
thorough grasp of how the database operates when you have to dig through
everything, and tearing apart a functioning database is a great way to learn
about various aspects of development.
in this particular case, a form that was built on the concept of an employee
being linked directly to an asset, is going to fail, because that concept
has been replaced with the indirect link provided by the linking table
(tblAssetAssignments). you can go through and tinker with the form until it
supports the new table relationships, or you might find it easier to simply
build a new form from scratch.
hth