Listbox value not save (1 Viewer)

darrenislearning

New member
Local time
Today, 13:49
Joined
Aug 9, 2021
Messages
24
Hello, I am very new to Access. I created a simple form to explore and learn.

I have this table, tblstudent and it contains these fields (ID, StudentID, FName, Interest). Interest, is a multi-select listbox.

I created a button to save the record but it is not saving my multi-select items. Or I need to use VBA to save? Any expert can guide me. Thanks
 

June7

AWF VIP
Local time
Yesterday, 21:49
Joined
Mar 9, 2014
Messages
3,669
Assume you want to use a multi-value field. This must be defined in the table design.

What code is in the button?
 
Last edited:

darrenislearning

New member
Local time
Today, 13:49
Joined
Aug 9, 2021
Messages
24
Must use VBA to save items selected with multi-select listbox. Do you want a separate record for each selection or are you trying to save to a multi-value field?
All multi select in one field (interest). I dont need to have comma, just new line in that field
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:49
Joined
Oct 29, 2018
Messages
16,572
Hi. If the form is bound, there's usually no need to create a save button. Access will automatically save the record for you.

With regards to the multi select listbox for interests, most developers will tell you to avoid using a multi value field (MVF) to do that. Instead, you should consider using a child table and a subform instead.
 

darrenislearning

New member
Local time
Today, 13:49
Joined
Aug 9, 2021
Messages
24
Is there any simple sample on the subform for my reference? I saw the subform but not sure how to use it. And in the future, i want to expand on the form where user have to login to save the record
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:49
Joined
May 7, 2009
Messages
14,091
sample with Student and subform of interests.
 

Attachments

  • students.accdb
    704 KB · Views: 101

darrenislearning

New member
Local time
Today, 13:49
Joined
Aug 9, 2021
Messages
24
Hi, I'm back again and I'm still struggling with the work. May I know can I don't do with a sub form as my form will be expanding and I am considering to have navigation control in the future. And the listbox value is not referencing to table. The purpose of the navigation form is to split the form into parts and the each tab will save the data into different tables.
 
Last edited:

June7

AWF VIP
Local time
Yesterday, 21:49
Joined
Mar 9, 2014
Messages
3,669
What do you mean by "form will be expanding" - expanding how?

What other tables?

You should probably provide your db for analysis.
 

darrenislearning

New member
Local time
Today, 13:49
Joined
Aug 9, 2021
Messages
24
Expanding with more fields and placed into tab control.
For now, I have tables for student particulars, courses taken, student nok details. All will linked from studentID

I have messed up my db and currently it is not working so I am unable to share my db
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:49
Joined
Feb 19, 2002
Messages
33,213
A subform with Interests is the way to go. Do NOT mush multiple values in a single field. It may look simpler but it is not. This violates first normal form and will make it difficult for you to change the Interests list as well as to use it for analysis. All columns must be atomic and indivisible. This is the same reason that you don't put all parts of a name or an address in a single field. It is just too hard to split everything back out again when you need the individual parts.
 

darrenislearning

New member
Local time
Today, 13:49
Joined
Aug 9, 2021
Messages
24
A subform with Interests is the way to go. Do NOT mush multiple values in a single field. It may look simpler but it is not. This violates first normal form and will make it difficult for you to change the Interests list as well as to use it for analysis. All columns must be atomic and indivisible. This is the same reason that you don't put all parts of a name or an address in a single field. It is just too hard to split everything back out again when you need the individual parts.
Thanks for advise.
 

June7

AWF VIP
Local time
Yesterday, 21:49
Joined
Mar 9, 2014
Messages
3,669
Even a 'non-working' db could be provided for analysis.
 

Users who are viewing this thread

Top Bottom