By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,292 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

Cascade Comobox.... i have trying for 2 weeks now! Please Help me.

P: 9
Hi, so i try everything! Nothing works for me always Problems xD

Let me Explain.

I have proudcts ,
I want to add proudcts by Combobox.
so first i want the user to pick Catagory and then MainType And then SubType and then Weight.

Catagory
MainType
SubType
Weight

So i devide my Proudct into 3 Tables
Lets say Catagory=Parit.

tblParit
Expand|Select|Wrap|Line Numbers
  1. ParitID|Parit
  2. ---1---|-Gold-
  3. ---2---|-Iron-

TblMaintype
Expand|Select|Wrap|Line Numbers
  1. MainTypeID|--MainType---|ParitID
  2. ----1-----|-Gold Sword--|--1----
  3. ----2-----|-Gold Hand---|--1----
  4. ----3-----|-Iron Door---|--2----

TblSubType
Expand|Select|Wrap|Line Numbers
  1. SubtypeID|SubType|Weight-|MainTypeID
  2. ----1----|-Long--|--33---|---1-----
  3. ----2----|-Short-|--45---|---1-----
  4. ----3----|--Half-|--67---|---2-----
  5. ----4----|-Finger|--32---|---2-----
  6. ----5----|-All---|--11---|---2-----
  7. ----6----|-Blue--|--88---|---3-----
So i create new form
Inside i have a sub form.
inside the subfrom i put 4 Combobox

1. CboParit
Expand|Select|Wrap|Line Numbers
  1. SELECT TblParit.ParitID, TblParit.[parit] FROM TblParit GROUP BY TblParit.ParitID, TblParit.[parit]; 
With AfterUpdate:
Expand|Select|Wrap|Line Numbers
  1. Me.CboMainType.Requery
  2. Me.CboMainType = Me.CboMainType.Column(0, 0)
  3.     Me.CboMainType.SetFocus
  4.     Me.CboMainType.Dropdow
n


2. CboMainType
SELECT TblMainType.MainTypeID, TblMainType.MainType FROM TblMainType GROUP BY TblMainType.MainTypeID, TblMainType.MainType, TblMainType.ParitID HAVING (((TblMainType.ParitID)=[Form]![Cboparit])) ORDER BY TblMainType.MainType;

With AfterUpdate:
Expand|Select|Wrap|Line Numbers
  1. Me.CboSubType.Requery
  2.   Me.CboSubType = Me.CboSubType.Column(0, 0)
  3.     Me.CboSubType.SetFocus
  4.     Me.CboSubType.Dropdown
3. CboSubtype
SameIdea
4. CboWeight
SameIdea

the subform is Datasheet.
My problem is when i choose new record it requery all of the recoreds and all vaules are gone.

Gif For Exemple:

Jan 30 '17 #1

✓ answered by PhilOfWalton

Sorry, I never use datasheets, only continuous forms (which are pretty similar providing the information can be placed on one line.

Your clever little GIF file appears to be working perfectly, except you don't need a dropdown for the weight.

It had me foxed for a moment till I saw the writing was in Hebrew and everything went from right to left.

What is the control source of the SubType Combo?
It should be something like
Expand|Select|Wrap|Line Numbers
  1. SELECT SubType, SubTypeID FROM TblSubTypes WHERE MainTypeID = " & CboType
  2.  
I am assuming that the Type Combo Box is bound to MainTypeID

On the AfterUpdate of the Type Combo Box you need
Expand|Select|Wrap|Line Numbers
  1. CboSubTye.Requery
  2.  
Phil

Share this Question
Share on Google+
3 Replies


PhilOfWalton
Expert 100+
P: 1,430
Unless I am totally misunderstanding things, I assume that once the type & subtype are selected, the weight is known.

So MainType = Gold Hand, SubType = Finger will give weight = 32

What am I missing?

Phil
Jan 30 '17 #2

P: 9
Yes you Right,
i try do that in a Datasheet view, but everytime i select a Subtype or Maintype, all the data in the previous column get Requrey and get blank.
there is a way to do it in datasheetview?
Jan 31 '17 #3

PhilOfWalton
Expert 100+
P: 1,430
Sorry, I never use datasheets, only continuous forms (which are pretty similar providing the information can be placed on one line.

Your clever little GIF file appears to be working perfectly, except you don't need a dropdown for the weight.

It had me foxed for a moment till I saw the writing was in Hebrew and everything went from right to left.

What is the control source of the SubType Combo?
It should be something like
Expand|Select|Wrap|Line Numbers
  1. SELECT SubType, SubTypeID FROM TblSubTypes WHERE MainTypeID = " & CboType
  2.  
I am assuming that the Type Combo Box is bound to MainTypeID

On the AfterUpdate of the Type Combo Box you need
Expand|Select|Wrap|Line Numbers
  1. CboSubTye.Requery
  2.  
Phil
Jan 31 '17 #4

Post your reply

Sign in to post your reply or Sign up for a free account.