I want to stored multiple data in one field named "Seriousness Criteria" using Checkbox. How is it possible for me to do so?
Thank you! 3 2655 zmbd 5,501
Expert Mod 4TB
This sounds like a violation of the Database Normalization and Table Structures practices used in good database design.
+ If you are talking about storing a list of possible values to be used as a checkbox, then the answer is yes and no. However, Yes is very difficult for the novice to implement and can make the future maintenance/upkeep a very difficult proposition as things invariably change.
+ If you are talking about storing the various checked values in the field then the answer is again, yes and no. However, the yes is somewhat difficult for the novice to implement and really should not be done in most cases as this violates the above normalization best practices.
If you can clarify the direction you are going and tell us how much experience you have in Access (or for that fact any) database application design we may be able to guide you in the right direction.
I agree with Zmbd that it would be best for you in the long run to break out these fields into separate data elements. The two big reasons for this: - Binding to a Control can be done without code. This means that a Continuous Form can be used to display and edit data. Unbound fields and Continuous Forms don't go together well and if the value of an unbound control changes on a continuous form, it changes for every occurrence of the control on the form.
- Reporting and Querying is much easier as you won't have to perform bitwise operations, which aren't bad, but not as clean as other forms of criteria.
If we haven't deterred you yet, then the following is one way to accomplish this.
Place these functions in a Module: - Public Function getBit(ByRef iValue As Long, ByRef iBit As Integer) As Boolean
-
getBit = (iValue And (2 ^ iBit)) > 0
-
End Function
-
Public Function setBit(ByRef iValue As Long, ByRef iBit As Integer, ByRef bSet As Boolean) As Long
-
' iValue - Number to use to set (or reset)
-
' iBit - 0 to 30, bit to set or reset in iValue
-
' bSet - True to set the bit, False to Reset the bit
-
If bSet Then
-
setBit = (iValue Or (2 ^ iBit))
-
Else
-
setBit = iValue And ((2 ^ iBit) Xor 2147483647)
-
End If
-
End Function
These are the bitwise Getter and Setter used to get and set the bits in the SeriousnessCriteria field.
The following code is an example pulled from a test database that has four checkboxes that are mapped to a single database field: - Private Sub Check0_AfterUpdate()
-
Call updateCheck(Me.Check0.Value, 0)
-
End Sub
-
-
Private Sub Check2_AfterUpdate()
-
Call updateCheck(Me.Check2.Value, 1)
-
End Sub
-
-
Private Sub Check4_AfterUpdate()
-
Call updateCheck(Me.Check4.Value, 2)
-
End Sub
-
-
Private Sub Check6_AfterUpdate()
-
Call updateCheck(Me.Check6.Value, 3)
-
End Sub
-
-
Private Sub Form_Current()
-
Me.Check0.Value = getBit(Me![Attributes], 0)
-
Me.Check2.Value = getBit(Me![Attributes], 1)
-
Me.Check4.Value = getBit(Me![Attributes], 2)
-
Me.Check6.Value = getBit(Me![Attributes], 3)
-
End Sub
-
-
Private Sub updateCheck(ByRef bValue As Boolean, ByRef iBit As Integer)
-
Dim lAttributes As Long
-
lAttributes = setBit(Me!Attributes, iBit, bValue)
-
If lAttributes <> Me!Attributes Then Me!Attributes = lAttributes
-
End Sub
-
How it works... - Form_Current decodes the value to be displayed for each of the Checkboxes and sets the checkboxes accordingly. This is performed whenever the current record changes.
- updateCheck() is a function that sets or resets a bit in the number that is saved to the database. This is called when a user changes the value of a checkbox.
NeoPa 32,556
Expert Mod 16PB
It may make sense to have this available for reporting purposes, but, as the others have said, storing and maintaining it is a big no-no.
The SQL to include in a query for this would look similar to : - Mid(IIf([Death],', Death','') & IIf([Hospitalisation],', Hospitalisation/Prolonged','') & ...,3,9999) AS [SeriousnessCriteria]
You can see where I've guessed at your field names. You would need to replace and extend these with entries for each field you wanted to include in the result.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: smen |
last post by:
hiye, can stored procedure return multiple @output's?
thanks for replying...
|
by: palani12kumar |
last post by:
Hi.....
I've a table that contains the students marks.
The fields in the table are:
Sno,m1,m2,m3,m4,m5,total,avg,grade.
im having ten records in the table in which, i've to update the grade...
|
by: Mervin Harshal |
last post by:
I need to know a way to pipe the output of an sql (select )statement to a stored procedure.
Eg:
The stored procedure is sp_rsch_filters param1,param2,param3
Requirement is to pass param1,param2...
|
by: muhammadrashidmughal |
last post by:
I need to know a way to pipe the output of an sql (select )statement to a stored procedure.
Eg:
The stored procedure is sp_rsch_filters param1,param2,param3
Requirement is to pass param1,param2...
|
by: dan |
last post by:
Hi,
I have a form that displays record fields. The record has a 'type' field.
I'd like to use different controls for one of the fields based on the type.
I initially thought of putting all...
|
by: bhappy |
last post by:
Hai All,
Im creating 2 formula fields in my crystal reports for displaying empname and salary like this,
abc 100
xyz 200
pqr 300
in code behind...
|
by: Whizzo |
last post by:
Hi all;
Here's a record in my table for you:
ID AcctNos Balance AcctTypes AcctOwners
20 3456,3457,3458,8766 12000 p,p,p,b John,John,John,Mary
I managed to generate it...
|
by: codemaster1 |
last post by:
How to show multiple values in crystal report using a single parameter.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |