Full Version: Linked Combo Boxes in forms
UtterAccess Forums > Microsoft® Access > Access Forms
I'm new here and pretty much an access novice. I hope you don't mind...
My problem is this... I have been asked to design a database for a company that sells charity merchandise worldwide. There are a number of different types of merchandise availiable, so I put them in a combo box.
eg Option #1
Option #2
Option #3 etc...

The trouble is, there are also more options availiable for each of the above options (so I put these in combo boxes as well, ie...
Option #1, choice a
Option #1, choice b etc

At the moment, these combo boxes are all in the same form and it can be very confusing and difficult to use. So, I what I want to happen is that when I choose an option from the main combo box - another combo box will pop up on to the form. Is this at all possible?
Is it also possible to store pictures of the different goods in the database somewhere so these can "appear" when I select goods?
Any help you can give me would be greatly appreciated. Thanks
Nat sad.gif
Hi Nat,
On the RowSource for the second combo, use this as criteria:
Formname is the Name of your form
combo_controlname is the Name of the combo control
on the AfterUpdate event of combo_controlname:

for pictures, store a drive:\path\filename in a text field
say you have a fieldname, I will call it PicPath, that stores the fully qualified filename (ie: c:\Data\Images\Picturename.Jpg), then this will show your picture
make an Image control on your form (icon with mountains and sun) with Name --> ImageControlName (change this to suit you)
put this code behind the form:
Private Function LoadImage()
   If Not IsNull(Me.PicPath) Then
      If Len(Dir(Me.PicPath)) > 0 Then
         Me.ImageControlName.Picture = Me.PicPath
         Me.ImageControlName.Visible = True
         Me.ImageControlName.Visible = False
      End If
   End If
End Function

on the AfterUpdate event of choosing an Item and also the form Current event (since the Item will change when you move to a different record):
now, you wish to also include a Browse button to choose the Image file ... but lets do that after this is working
OK I have another problem. What dies the "Me." stand for?
very time I try running the code it says "Microsoft Office Access cannot find the macro Me.
I'm sorry if this sounds like a stupid question but I'm only new to Access.
Hi Nat,

"Me" stands for the form or report that the code is behind. Every form or report can have a module attached to it (View, Code from the menu in design view).

"Microsoft Office Access cannot find the macro Me."
ounds like you are putting code directly into the Event Property ...
Here is more information about Code Behind a Form (CBF)
How to enter a live e-mail... -- Code Behind Form (CBF)
There is more good reading:
Access Basics
30-page Word document on Access Basics (for Programming) -- it doesn't cover VBA, but prepares you for it because it covers essentials in Access

and, after you get that under your belt...
on learning programming, here is a link for you: download the first 3 chapters of VBA book (rest not written yet)

The first part of the book uses Excel to program -- and then, the chapters that aren't written yet get into Access -- but the basics of VBA are the same.

This would be excellent for you to read ... no hands on, just reading for these chapters.
VBA chapter 1
VBA chapter 2
VBA chapter 3
Thanks for that info Crystal. I suspect I may have to burn the midnight oil a fair few nights this week! ROFL
Hi Nat,
You are welcome wink.gif I have now posted an updated version of Access Basics -- this one has 100 pages and screen shots wink.gif

Access Basics -- updated!
8-part free tutorial that covers essentials in Access
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.