ms-access


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])

Related Links

Pivot combo box table in ms access
How to perform inexact matches on two data sets
Query for Nearest Dates, along with respective values
MS-Access store the ID number in master table instead of the text
Getting date from a query which is not showing exact as entered in table
MULTIPLE JOIN IN MS ACCESS
How can I get back the MS-Jet DB engine?
MS Access: binding toggle button in a continuous form with an aggregate query
I need to replace the value for a running variable
Microsoft Access VBA INSERT SQL statement
MS Access: if I put a button on multiple rows form, can I detect on which row the button was clicked
Updating table in SubForm with new changes to structure from linked table
MS Access issue : date picker not appear after choosing certain day
MS Access 2016 All subform buttons grayed out and font over-sized after upgrade
Summing a column in an Access subform using the Total feature
Filtering the import from DB2 Table into Access

Categories

HOME
maven
ibm-bluemix
log4j
multithreading
testng
amazon-ec2
drivers
q
getelementsbytagname
react-redux
packages
disassembler
pivotal-cloud-foundry
enterprise-library-5
datastax-java-driver
indesign
django-imagekit
dacpac
vault
google-cloud-ml
task
orchardcms
messages
netflix
database-replication
sms-gateway
contextmenu
shared-hosting
firefox-webextensions
user-interaction
react-css-modules
tooltipster
fopen
replaceall
objectanimator
.net-4.0
repo
android-kernel
geopositioning
host
scaffold
objectlistview
c11
theano.scan
jna
angularjs-factory
leading-zero
password-encryption
logfiles
google-datalayer
libusb-win32
media-player
nbconvert
lync-client-sdk
redundancy
color-picker
vmware-tools
rotativa
phishing
mongocsharpdriver
lttng
disque
actionbardrawertoggle
python-stackless
historian
hsv
unity-networking
iad
rtbkit
cartesian-product
cyclomatic-complexity
comobject
ibaction
method-parameters
event-bubbling
oberon
angular-local-storage
skos
geonetwork
block-device
ng-animate
java.util.concurrent
client-side-templating
terminfo
tld
htmlcleaner
concurrent-collections
imdbpy
ms-project-server-2010
sqlperformance
mqx
interface-orientation
selected
simba
nsnetservice
bluepill
online-compilation
netbeans-7.1
imac
iweb
backcolor
django-notification
signal-handling

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App