cascading combo reset...

asmodius

Registered User.
Local time
Today, 16:07
Joined
Oct 22, 2003
Messages
60
Hey guys, Thank you for all your help thus far figuring out cascading combo boxes. I've searched and read quite a few of the posts and they have been indespensable. I have one last question.

I have a cascading combo of two boxes. When you select the item in the first box you get the proper corresponding list in the second. my problem is that if I change the item in the first box for some reason I get the same list from the first selection in the second... How do I make the second box reset to the proper list when the first is changed?

Thanks.
 
In the AfterUpdate event of your first combo include:

Me.SecondComboName.Requery


Note: If your second combo already has a selection, it will remain, but may not display. ie: the value remains, but is not part of the new rowsource, and thus appears blank. If you consider the "old" selection to be invalid, you may want to remove it before the requery.

Thus:
Code:
Me.SecondComboName = ""
Me.SecondCombo.Requery

Brad
 
Have a look at the example on this this thread if you are stuck.
 
error?

O.k. so I did what I think is exactly what you guys have running I opened the event procedure in code view and copied exactly whats in the examples I have except substituting my field names of course. Now I get the following error.

The expression AfterUpdate you entered produced the following error: file not found

which file wasn't found? Please help. I can post a copy of my db if you want.
 
Now its worse..

So I tried to fix that some more and now I get invalid procedure call? what am I doing wrong?
 
bradcccs said:
In the AfterUpdate event of your first combo include:

Me.SecondComboName.Requery



Thus:
Code:
Me.SecondComboName = ""
Me.SecondCombo.Requery

Brad

I think that perhaps I havent' set the name of the field correctly. It seems to think it cannot find the field. What is that part of Me.SecondComboName = "" for? is that how I would set the name of the combo box to requery?
 
should I be able to compile this?

When I try to complile the simple command I get an error: Invalid Procedure Call or Argument.

Am I missing some kind of connection on the code side that I don't know about. This is what I have so far.

Option Compare Database

Private Sub Discription_AfterUpdate()
Me.specific.Requery
End Sub

Private Sub Form_Close()
DoCommand.OpenForm "switchboard"
End Sub


Discription (i know its mispelled i didn't do that but thats the name of the field) is the field at the beginning of the cascade, specific is the field that changes depending on the selection in discription. what am I doing wrong here?
 
Code:
Private Sub Discription_AfterUpdate()
    Me.specific.Requery
End Sub

Private Sub Form_Close()
    DoCommand.OpenForm "switchboard"
End Sub

The first thing that scares me is that that you can;t spell description but that is beyond the point.

The second thing that I query is your VBA:

"DoCommand" should be "DoCmd"
 
Fixed that, any more help....

I still get an invalid procedure call or argument and the first line is highlighted in yellow in code mode.

Private Sub description2_AfterUpdate()
Me.specific2.Requery
End Sub

Private Sub Form_Close()
DoCmd.OpenForm "switchboard"
End Sub


Whats wrong with the first line? that is the name of the field that I am in, and the second line contains the name of the field I want changed if the first one changed, this is in accordance with many examples I have seen. Thank you for your help. I appreciate it.

cheers.
 
I DID IT!!!

Mile-O-Phile, I really gotta thank you. I figured it out, I was missing one line in the event. Here is the code I should have had.

Private Sub description2_AfterUpdate()
Me.specific2 = ""
Me.specific2.Requery
End Sub

Thanks for your help.

cheers.
 
Re: I DID IT!!!

asmodius said:
Mile-O-Phile, I really gotta thank you. I figured it out, I was missing one line in the event. Here is the code I should have had.

Private Sub description2_AfterUpdate()
Me.specific2 = ""
Me.specific2.Requery
End Sub

Thanks for your help.

cheers.

So I'm a freaking liar. It worked for a minute then back to the same problem. Any more words of advice?

thanks.
 
I finally did get it.. This might help other people

So I finally figured out what was wrong. You were all telling me things that were exactly right, my problem was on the rights end. See, I walked into the job of this database that had already been started by somebody else, so they owned the DB. So any changes I made at the code level didn't hold. That is why I was getting the same error all the time no matter what I did. So the solution was to create a new database, import the old one in and then make my changes seeing as how I am the owner of the old one. Thanks to all of you for your help it has been indespensible.

cheers,

andy
 

Users who are viewing this thread

Back
Top Bottom