473,379 Members | 1,201 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Query to Assign Numerical Values to Text Records based on various criteria

Hello,
I am struggling with finding a solution on how to assign numerical values to text records based on various criteria. I have a table with survey responses where each column has text records for responses with various criteria. Thus I want to create a query that will change or assign numerical values to this text records as follows:

If response is "Agree", then it is 5
If response is "Somewhat Agree", then it is 3
If response is "Disagree", then it is 1

Each column may have any or all of this responses.

What is the best way to go about it?
Jun 25 '13 #1
3 3404
zmbd
5,501 Expert Mod 4TB
I would create a calculated field using either the switch or choose functions. You can also use a set of nested IIF conditionals.
Links:

Switch Function
Evaluates a list of expressions (expression: Any combination of mathematical or logical operators, constants, functions, and names of fields, controls, and properties that evaluates to a single value. Expressions can perform calculations, manipulate characters, or test data.) and returns a Variant value or an expression associated with the first expression in the list that is True.
Choose Function
Selects and returns a value from a list of arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.).
Please understand that most of us are either unable to open/view attachments as we're at work, or will not open an unsolicited attachment just as a matter of Best Safe Computing Practices (esp. #6 and #7). This should in no way be taken personally. It is much better to have a well worded/phrased description of the goal, the current issue, exact errors, and so forth as these will turn up in the search engines for others to find should they be in the same or simular situation as you find yourself in today.
Jun 25 '13 #2
Thank you ! So I was able to assign numerical values to fields as follows:

" Switch([My counselor gained my confidence and trust by their knowledge]="Strongly Disagree",1,......)

However, how do I or can I permanenetly change data type to a Number in the same string?
Jun 26 '13 #3
zmbd
5,501 Expert Mod 4TB
You can make an update query. The basic information is here: Introduction to queries (V2010) Be aware of the fact that if you do update within the same field as the text reply, then the numeric value will be treated as text as it's stored within a text field. You would be well advised to create a numeric field and more than likely a few other changes are required in your database.

However, carefully consider why you need to do this, the query does the value change for you at run time.


Also, and I am going to go slightly off topic here; if you are using a field for each question, then you're going run into a lot of issues in maintaining your database... the field name - [My counselor gained my confidence and trust by their knowledge] - is truly (IMHO) awful... you might like to read thru:> Database Normalization and Table Structures. A well normalized database will save you a ton of time and hassles.

The reason Normalization is so important within a database is best shown by example - trying to keep within what I think you are using:

Each of the following tables would have a primary key that is normally unrelated to the record information.

[tbl_attendanceinfo]
This table would have your student and teacher information, at least name, student id.

[tbl_course]
This table would have the course id and name

[tbl_questions]
This would have the various questions such as your "My counselor gained my confidence and trust by their knowledge"

[tbl_txtresponse]
This would have the text and numeric responses

[tbl_QandA]
This would relate the above tables to each other. Note, in this case, there would not be any text in this table, just numeric values relating back to the primary keys of the other tables.

Now if you need to change a question for grammar or legal requirements, you do so once, without altering any tables NOR any related queries!

Or say that you need to Add 'Totaly Agree = 10, Agree = 8, ..." now you add and change that information within [tbl_txtresponse] because the primary key doesn't change, the original answer recorded in [tbl_QandA] is retained (say it's "Agree") however, the weighting is updated (from a 5 now to an 8) for all of the questions within the table (however, there may be times where you'd want to retain the original value and that is another day).

Your forms and queries will have your lookup fields for the human readable side

OK now that I am totally off topic, I'll stop… if you get into problems normalizing your database we can deal with it in a new thread so that we can keep the questions straight.
Jun 26 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dom Boyce | last post by:
Hi, I have a table containing analyst information, and each analyst has a unique ID (30 analysts, analyst IDs are 1,2,3,...29,30). I am creating a search form which feeds an underlying query...
1
by: arthur-e | last post by:
How can you select records based on more than one combo box - I have a combobox that selects records based on name (I'm sure this has been asked a thousand times - web site answer/link could be...
1
by: davidevan | last post by:
What I'm trying to do is set a players division according to their age. So if age is 8, update division to junior, if age is 9, update division to medium, if age is 10, update division to pee wee,...
1
by: mrkselm | last post by:
Hi, I am stuck with a problem in MS Access which does not occur in SQL Server and I have been banging my head against the wall for a couple of days now trying to resolve it. Namely, when I...
2
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number...
6
by: BEETHOVEN | last post by:
I have an option group called Issue_Type on my main form F1_Member_Demographics_Main. When I select one of the 3 options on the main form from the option group Issue_Type I want to limit the sub...
4
by: gio1405 | last post by:
I am kind of a beginner in C# and I have to do a program in which i have to add all the numerical values of the text boxes. My code starts like this: float.nTxtbox1 = float.parse (txtbox1.text); ...
1
by: rachbret | last post by:
Hi, I created a database with a table that has customer info - including sales history. I want to create a form so that i can search based on various criteria (first name, last name, purchase date,...
0
by: TheBlackDragon7 | last post by:
.. At least, I think that's what I'm asking for... Please bear with me as I try to explain my setup and my question. :) I have a database set up for products. each product (obviously) has a...
3
by: slenish | last post by:
Hello, Im having trouble getting a form to fill in mulitple text boxes based on a query. What I have is a form where I can enter the Criteria information to look up a record. You have to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.