Access Developer 38
VBA for Multivalued Fields, Images in Form Columns
This class has two primary goals. First, we're going to learn how to work with Multivalued Fields. Now, yes, I know I've been telling you from the beginning not to use them. They're evil. However you may have already used them, or you may encounter a database that someone else has built that used them. In either case, I'm going to teach you how to programmatically access the data in those fields and to move it over to a properly relational second table, and then use a multi-select listbox to handle them properly.
Then we will take a look at a problem that one of my students asked me about. It's very easy to display multiple images side by side (in columns) in a report, but that same functionality doesn't exist for forms. If you want to create an "image gallery" it's very difficult. But... I'll show you how to do it in today's lesson.
In Lesson 1, we will learn about multivalued fields (MVF), what they are, how to use them, and why you should avoid them at all costs. Yes, they're on my Evil Access list.
In Lesson 2, we will learn how to read the values from an MVF using a recordset loop. We'll also see how to programmatically add values to a multivalued field.
In Lesson 3, we will replace the MVF with a proper junction table. We'll learn how to loop through all of the customer records and export the MVF data to the junction table. We will create a text box to display the items as a comma separated list, like an MVF does.
In Lesson 4, we will learn how to create a popup form with a multi-select list box to modify the data in the new MVF replacement (junction table). You could do this just with a list box on the main form, but I like the popup. :)
In Lesson 5, we will learn how to create a product catalog showing multiple images per product. Yeah, we're going to cheat and use a customer form, but the concept is the same whether it's products, customers, employees, properties, or whatever you want. It's basically displaying multiple images per record.
In Lesson 6, we will learn how to display the products in multiple columns in the report using a subreport.
In Lesson 7, we will learn how to display the images in multiple columns in a subform. This isn't as easy as it sounds. There's no setting for this and Access can't handle it natively. This will involve some fancy recordset programming, a temporary table, and several events... so I hope you watched Developer 16. We're essentially creating an "image gallery" in our Access forms.
In Lesson 8, we'll add some embellishments to our image gallery. We'll add buttons to add, edit, delete, and browse through the images. We'll create a popup form to handle most of that. We'll learn how to use a global function as an event handler instead of using event procedures all the time. We'll learn about passing variables to functions as variants so they can accept null values.
Enroll now so that you watch these lessons, learn with us, post questions, and more!
Please feel free to post your questions or comments below. If you are not sure as to whether or not this product will meet your needs, I'd rather help you before you buy it. Remember, all sales are final. Thank you.
microsoft access, ms access, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #instruction, #learn, #lesson, #training, #database, image gallery, multivalue fields, mvf, object invalid or no longer set, multiple images per record, multiple columns in a form, function as an event handler, event procedure, passing variants to allow null values
Check out these other pages that may be of interest to you: