Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Update an MVF
Nigel Hancock 
    
3 years ago
I have now added an MVF to my table, but I need to clear those values every time the database is opened, I have set it up to action when clicking my Enter button on my Menu Form, I have two field that need clearing out (Required & Harmed) the required one is just a Yes/No field and that works fine but Access will not let me run an Update or Delete query on an MVF Field, are there any solutions?
Scott Axton  @Reply  
        
3 years ago
I see that you went against the advice given in your last post.  I'm afraid that is not supported here as the MVF is on the Evil Access Stuff list and most of us just don't use it.  This is one of the reasons why.  They are notoriously difficult to work with.

If you haven't already watched it check out the Multivalued video.

A better alternative is using a Many-to-Many relationship.
Kevin Yip  @Reply  
     
3 years ago
To clear all values in a multivalue field named MVField1 in a record identified by the primary key ID1, run this query:

     DELETE FROM Table1.MVField1.Value WHERE Table1.ID = ID1

You can't do it in the query designer.  You have to manually edit the SQL.

P.S.  Hi Scott, yes, multivalue fields can be challenging, but in certain cases they can help greatly.  The biggest hurdles are queries.  If the user can overcome the challenges of making delete queries (which isn't so bad above) and append queries, then MVFs are a viable solution.  The one big caveat is that SQL Server doesn't support MVFs.  If you anticipate migrating to SQL Server, that's a no can do.
Kevin Yip  @Reply  
     
3 years ago
And here is what an update query looks like.  To insert the value "ABC" to the multivalue field that belongs to a record with primary key 1:

     INSERT INTO Table1 ( MYField1.Value )
     SELECT "ABC" AS Expr1
     FROM Table1
     WHERE Table1.ID=1;

Note that this can insert values that aren't in the combo box.  Even if your combo box is set to "Limit to List", it will still accept such nonexistent values.  After the update, such values will even show up in your combo box with checkmarks next to them.  Uncheck them and they'll be gone, like before.  This is another caveat that gives people pause.
Nigel Hancock OP  @Reply  
    
3 years ago
My head is hurting (It's me not you guys)

Ok, I have a button called "Enter" on a form that I set up to open a form and also run an update query to clear the field "Required"

I have a table "Sub Risks" which has an MVF called "Harmed" which has three entries, Contractor, Employee and Public.

Every time I click the "Enter" button I want the MVF fields to be deleted, so when the new form opens the MVF field is back to a state of Null

Now I have been opening the Event procedure for the "Enter" button and adding the above code from Kevin ( and changing what I think needs changing) and I am getting nowhere, can you help please?
Kevin Yip  @Reply  
     
3 years ago
Sorry, the delete query should be below, a slight correction on the syntax:

     DELETE Table1.MVField1.Value FROM Table1 WHERE Table1.ID = ID1

How familiar are you with queries in general?  Working with MVF inside queries is tricky, so a good knowledge on queries is best.  For instance, queries that update MVFs cannot update non-MVFs.  Yet another caveat.
Nigel Hancock OP  @Reply  
    
3 years ago
So my code would look like this:

    DELETE Sub Risk.Harmed.Value FROM Sub Risk WHERE Sub Risk.ID = ID1

I am not very experienced with Access at all, just starting out.

so do I enter the Event procedure for the @Enter@ button and add this line into it?
Nigel Hancock OP  @Reply  
    
3 years ago
Forgot to mention, I am trying to clear all entries in the Colum "harmed" not just one record
Kevin Yip  @Reply  
     
3 years ago
To delete all MVF values in all records, remove the WHERE clause:

     DELETE Table1.MVField1.Value FROM Table1

If you have spaces in your table name, you need to enclose it with square brackets:

    DELETE [Sub Risk].Harmed.Value ...

It's generally not advisable to have spaces in tables names and field names, because you don't want to use [ and ] all the time.

You use the button's Click event.  Event procedures use VBA.  To run the delete query in VBA, you need to write it in a way that conforms to VBA's rules:

    CurrentDb.Execute "DELETE Table1.MVField1.Value FROM Table1"

All this requires some knowledge on SQL, VBA, table design and naming conventions, etc.  It's best to take some beginner's courses on these first.  You can keep asking me questions, but you may achieve your goals (a lot) faster with some courses.
Nigel Hancock OP  @Reply  
    
3 years ago
Kevin, thank you so much for your time and understanding, I have no managed to set it all up

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 12:12:46 PM. PLT: 1s