Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdowns dependent on other dropdown 2

Status
Not open for further replies.

lholgerg

Technical User
Mar 12, 2001
15
DK
I have a dropdown menu that i want to make dependent on another the Row Source date i taken from is.

SELECT [Partner].[Name] From Partner;

I want to make the choices dependent on a field called partners


Hope someone can help
 
Hi there,
In the criteria of your combos query under partner add something like:
=Forms!nameofform!nameofcombo1
You should set a default value to "combo1", and in the forms "on load" and combo1's "after update" events add:

Me.NameofCombo2.Requery

This should work fine!

Gord
ghubbell@total.net
 
Thanks it works - but the last thing you wrote doesn't.

I have added "Me.TheNameOfTheCombo.requery"

but I get an error that it cant fin the macro me.

hope you can help
 
You have to go to the VB enviroment:
In the after update event: You should see "Event Procedure". Click on the ellipse "..." button just to the right to open VB. It will label up a "sub" for you. Now type in between the title and the "end sub":

Me.TheNameOfTheCombo.requery 'Not literally of course...

Close & save and give it a go! Gord
ghubbell@total.net
 
Yes - I've tryed that, but it still tells me that the macro me. isn't there.

And Yes i am writing the name of the combo - infact i am chousing it fron a list that appers as soon as I but a .

Now I can't delete the thing(the "me.") I keeps giving me the error in spite of the fackt that i have deleted the command

 
Hit Ctrl+Break or shut down Access and restart. Then go and wipe off the offending line in VB. Try this line instead:

Forms![NameOfThisForm]![NameOfTheCombo].Requery

All "Me" is is the form its self. Check carefully the Name of the combo, not its Control source. Gord
ghubbell@total.net
 
Hurray It works

Thanks a lot

But how do i clear combo2 box when i select something new in combo1. As it is now the name in combo2 doesn't update at the same time as I select a new in combo1

 
You have to have the same "requery" both when you load the form (to keep things tidy) and in the "After update" event of your Combo1. The after update of combo1 means as it sounds: after you update it do ... (requery combo2). As combo2 is now dependant on the value of combo1 (via the query) this should work and give you the associated result. Give it a check over & keep trying! Gord
ghubbell@total.net
 
No - I works fine when i select a new i combo1 the choices i combo2 canges.

BUT if I want to changes it again, I change combo1 - and them the choises in combo2 have also changed as they should, but in the field there stille is the choise from before.

What I want is to clear the choise in combo2 when I pick a new thing in combo1
 
I think I see what you're trying to do. add this line just before the other stuff in Combo1's After Update:
Forms![NameOfForm]![NameOfCombo2]= Null
This should "empty" it before the requery. I hope this will work for you!

Gord
ghubbell@total.net
 
DAMM - How do I make it work it in a subform

The form that it works in is a subform i another, and the entyre thing works when only the subform is open but not when i open it in the motherform.

Life just got a lot worse
 
Change your lines to something like this:
Forms![NameOfForm]![NameofSubFormASSeenbytheMainForm]!Form![NameOfCombo2]= Null etc...

Check your query too!
Gord
ghubbell@total.net
 
Sorry I hit the wrong button there!
Change your lines to something like this:
Forms![NameOfForm]![NameofSubFormASSeenbytheMainForm].Form![NameOfCombo2]= Null etc...
Gord
ghubbell@total.net
 
thanks Gord, i was looking for something very similar to this, you got my vote! :eek:)
 
It now want me to "Enter Parameter Value" when I want to chouse something in combo2.

It does not complain whit the combo1 but only when I select combo2

 
Are both of your combos on the subform? If so then go back a step or two, ignore calling "from" the main form, BUT make sure your combos query criteria says:
Forms![NameOfForm]![NameofSubFormASSeenbytheMainForm].Form![NameOfCombo1]

Gord
ghubbell@total.net
 
I am not sure what you meen but my subform has the event on efter update and so does my combo1
The lines are

Forms![NameOfMainForm]![NameOfSubForm].Form![combo2] = Null
Forms![NameOfMainForm]![NameOfSubForm].Form![combo2].Requery

NameOfSubForm = NameofSubFormASSeenbytheMainForm & the mane of the subform
 
If Both combos are on your subform:

In the Mainforms "On Load" event you need:

Forms![NameOfMainForm]![NameOfSubForm].Form![combo2].Requery

In combo1's "After update" event you need:

Forms![NameOfSubForm]![combo2] = Null
Forms![NameOfSubForm]![combo2].Requery

In the queries criteria for Combo2:

=Forms![NameOfMainForm]![NameOfSubForm].Form![combo1]

Whew!
Gord
ghubbell@total.net
 
I Finaly got it to work

I´t was a little diffrent then Gord's solution

In my Mainform's on load the line is

Forms![NameOfMaster]![NameOfSubform].Form![Combo2].Requery

In the subform's "After update" the line is

Forms![NameOfMaster]![NameOfSubform].Form![Combo2]= Null
Forms![NameOfMaster]![NameOfSubform].Form![Combo2].Requery

In Combo1's "after update" the line is

Forms![NameOfMaster]![NameOfSubform].Form![Combo2]= Null
Forms![NameOfMaster]![NameOfSubform].Form![Combo2].Requery

In the queries criteria for Combo2:

=Forms![NameOfMaster]![NameOfSubForm].Form![combo1]


Thats is - easy peasy japanesy

A lot of thanke to Gord :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top