Full Version: Linked Combo Boxes in forms
UtterAccess Forums > Microsoft® Access > Access Forms
natty444
Hello
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
strive4peace
Hi Nat,
On the RowSource for the second combo, use this as criteria:
forms!Formname!combo_controlname
WHERE
Formname is the Name of your form
combo_controlname is the Name of the combo control
on the AfterUpdate event of combo_controlname:
CODE
   Me.combo2_controlname.requery

~~~~~~~~~~~~~~~
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:
CODE
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
      Else
         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):
=LoadImage()
~~~~
now, you wish to also include a Browse button to choose the Image file ... but lets do that after this is working
natty444
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.
Cheers
Nat
strive4peace
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)
http://www.utteraccess.com/forums/showflat...;Number=1438041
~~~
There is more good reading:
Access Basics
http://www.utteraccess.com/forums/showflat...;Number=1220772
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
http://www.utteraccess.com/forums/showthre...;Number=1002042
VBA chapter 2
http://www.utteraccess.com/forums/showthre...;Number=1002044
VBA chapter 3
http://www.utteraccess.com/forums/showthre...;Number=1002046
natty444
Thanks for that info Crystal. I suspect I may have to burn the midnight oil a fair few nights this week! ROFL
strive4peace
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!
http://www.utteraccess.com/forums/showflat...;Number=1595005
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.