Multivalued field (1 Viewer)

zezo2021

Member
Local time
Today, 07:33
Joined
Mar 25, 2021
Messages
381
Hello friends

How can I save the Multivalued field to the normal field string?
for example the value

1,2,3

can be normal string 1,2,2 without dropdown or anything related to a multivalue field

Thank you
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:33
Joined
May 21, 2018
Messages
8,525
Not sure what you mean. Would you like to do the same thing as a MVF without using a MVF? Obviously you can simply store the string "1,2,3", but then you really cannot do anything with it easy. Here is an example of a fake MVF that uses a normalized junction table.
You can do something like that where you store your values in a traditional table and then use the concatenate to display them.
 

zezo2021

Member
Local time
Today, 07:33
Joined
Mar 25, 2021
Messages
381
Hello
example
I have a field containing multivalue
for example
category (multivalue)
1,2,3
5,6,3

I want to convert these value to short text field

category (multivalue) Cat(ShortText)
1,2,3 1,2,3
5,6,3 5,6,3
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:33
Joined
May 21, 2018
Messages
8,525
If I understand you correctly you have a MVF (lets call it 'MVF_Values') and now you have created a new text field in the same table (lets call it 'ConcatValues'). You want to take the MVF values and make a string with them and store it.
I can do this and have the code, but I am out this weekend for a wedding. If someone does not get back I can get to you by Sunday.
Basically
1. You will the recordset of your table.
2. For each record with the MVF you will get a second recordset. The value of the MVF field is a second recordset with the MVF values
3. You will loop the second recordset doing a simple concatenation.
4. You will do an insert query of the concatenated string into your new text field

See close example
 

Mike Krailo

Well-known member
Local time
Today, 01:33
Joined
Mar 28, 2020
Messages
1,043
Here is your example with slightly modified names to make it easier to read and a working query.
 

Attachments

  • DB_v1.accdb
    740 KB · Views: 178

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:33
Joined
Feb 19, 2002
Messages
43,233
I know this is what you asked for but it is the worst possible solution. I would rather see you stay with the MVF and learn the necessary SQL syntax to control it than mush the values together. Perhaps you'll come to that conclusion yourself once you try to do anything with the mushed data.
 

keviny04

New member
Local time
Yesterday, 22:33
Joined
Mar 28, 2018
Messages
5
The OP probably didn't like MVF and wanted to switch. I've found MVF to be most useful when I need a "choose all that apply" type of user input. A MVF is shown as a drop-down list of checkboxes, which is easy for the user to operate and to understand its purpose. For instance, a search form may allow the user to enter multiple search criteria. The user checks the choices on the drop-down list, and a query can be easily made for the selected choices by using a Recordset loop to construct a comma-separated list of the selected items, and then using the SQL:

Code:
SELECT * FROM MyTable WHERE field1 IN ( comma-separated list of user's choices );

Of course, MVFs are frowned upon because they are not "atomic" (I think that's the term) data required by traditional relational databases.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:33
Joined
Feb 19, 2002
Messages
43,233
The OP probably didn't like MVF and wanted to switch.
But the solution is NOT to mush a bunch of values into a single field. When you have more than one value you have many and many REQUIRES a separate table.
Of course, MVFs are frowned upon because they are not "atomic" (I think that's the term) data required by traditional relational databases.
The MVF uses a separate table to store the data correctly so it is "atomic". Experts object because the properly normalized table is hidden and therefore you have to use special SQL to access the data.
 

Users who are viewing this thread

Top Bottom