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

Is it possible to change Msysobjects in ms access
How can I make MS-Access choose a different/the right execution plan for my query
Access 2007 Reports - How to 'unfix' fields?
Hide Access Options
MS Access “record changes” log
Format combox in Access 2007
MS Access how can a subform get the value from another subform?
Can you use ADO to edit table schema in MS Access?
Access 2010: 'the expression cannot be used in a calculated column'?
ACCESS SubForm: trying to add records
Checking social security numbers and business identity codes in Access 97
MS Access VBA Substitution Cipher Encrypt/Decrypt
How to get SQL from column/query schema in Access
MS Access sub-sub forms
Access 2010 web compatibility error: ACCWeb107019
MS ACCESS: Populate a subform with data from another table

Categories

HOME
minimum-spanning-tree
mockito
comparison
layout
tesseract
maven-3
amazon-ecs
binary-tree
callback
adfs
slurm
google-apps-marketplace
timeout
decomposition
jsprit
graphlab
predix
immutable.js
zapier
tokenize
cloudhub
tar
extjs5
core-text
crystal-reports-2010
p-value
su
spark-jobserver
selectedindexchanged
chromebook
xacml
opentype
webkitspeechrecognition
stormpath
yadcf
airconsole
jspresso
usbserial
commit
wallpaper
appfabric
io-redirection
ansible-playbook
sfdc
gzipstream
ruby-on-rails-3.1
outlook-api
unixodbc
auto-update
long-polling
azure-application-gateway
qsslsocket
tropo
svmlight
recursive-datastructures
colorama
lift-json
capacity
iso8601
titanium-android
ado.net-entity-data-model
dstu2-fhir
player
gstreamer-0.10
ready-api
pickadate
fadeout
photobucket
historian
jfugue
ruby-2.2
feedback
dia
relocation
fpml
cctv
neolane
article
tld
phpthumb
terminal-services
floating-point-precision
ccss
apc
dataadapter
cassini-dev
factory-method
rdoc
datawindow
pysimplesoap
ticoredatasync
osql
jquery-ui-layout
punbb
adk
gwt-ext
mercurial-server
wise
infrastructure
libs
backcolor
ti-dsp
data-driven
avatar
zend-decorators
ubuntu-9.04
data-acquisition

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App