Field Display Question
I am working on a personnel accountability system, and I have a question about getting a field to display a value based on a value in another table that is a sub-report of the same form. For instance, I have a tabbed interface, and the first tab is a snapshot of the person, vital data and such. I have a tab that lists retention information. The tab has a sub-report that links to another table that stores all of the flags (adverse actions) for employees. These two tables are linked together with a relationship, linking each flag to an individual employee. I would like to have a field on the first tab titled FlagSnapshotdisplay either a value of Flagged or Not Flagged based on the value of the field FlagStatus from the other table. The field FlagStatus form the other table has possible values of Active, Removed, and Permanent. So again, if value in field FlagStatus in table Flags equals Active, I would like the FlagSnapshotfield in table Personnel to display Flagged. I also need to set conditions so that if the field FlagStatus in table Flagshas the value of Removed, then I need the field FlagSnapshotto display the value of Not Flagged. There are a few other values too in field FlagStatus, but only two values in the field FlagSnapshot. Also, it is possible for one employee to have multiple flags, and I need to make sure that all of them are taken into account. If the table Flags has two or three flags for the same employee and one of them reads Removed and the other reads Active, I need the flag snapshot field to display a value of Flagged. I apologize in advance for the long explanation. Also, this is not homework, it's a project I am working on at work to make things more easily tracked.
I would go with a mix of VBA and SQL, assuming you have normalized data structure (at least partially). For example, I would expect to have table FlagStatus to be a separate table and linked to other tables. Step 1: Add Column Priority to the FlagStatus table that lists ALL FlagStatuses: Step 2: Create a query (GetFlagStatusQuery) that returns FlagStatus with highest priority for a particular Employee: Step 3: Create a function that returns the desired FlagStatus representation. Something like this: Function GetFlagStatus(employeeId As Long) As String Dim rs As Recordset Dim qdf As QueryDef FlagStatus = "" Set qdf = CurrentDb.QueryDefs("GetFlagStatusQuery") qdf.Parameters("EmployeeId_parameter") = employeeId Set rs = qdf.OpenRecordset() If rs.RecordCount > 0 Then Select Case rs("FlagStatus") Case "Active" FlagStatus = "Flagged" Case "Removed" FlagStatus = "Not Flagged" End Select End If End Function Step 4: Use the GetFlagStatus function in your form/tab and pass EmployeeId parameter from the Form. For example, for a textbox control the source would be: =GetFlagStatus([EmployeeId])
How can I stop my subform from autoscrolling when an item is being edited?
How to autofill a field from a variable in Access 2007
using dlookup in a text box
Using Like function in Access
Any reason to run JETCOMP on smaller MDB file? [closed]
how to clear text box inside a macro?
Access 2007 referential integrity without using lookup within table
Access Query If/or condition
need to refresh subform based list box selection in access 2007
Error when opening the mainform before subform
VBA Set Recordet using a variable table name
Access 2007: crosstab view to insert values into a database
A Form/DataSheet using filtered data, can new records default the filtered data?
Building forms in Access 2007 for each category in a table
Access How to save text in a specific table?
Access 2010: Automatic update of a value of a field