Enabeling seccond combo based on previous

Gentleviking

New member
Local time
Tomorrow, 01:58
Joined
Oct 13, 2006
Messages
8
Hello!
I have honestly spent the better part of the past two days searching this forum and trying (but failing) to find a solution to my problem.

I know that my question has been asked many times, and several possible solutions have been given... however, none of them work for me:-( Oh, by the way, I just started using Access (2003) this Monday, so please IF there are anyone that can offer assistance, please do so in silly detail...

I have a form with several combos. One combo I would like to enable only if one specific choice is selcted in the previous combo. The solution given to many before me is to enter the following in the After_Update field of the first Combo:

Private Sub Source_AfterUpdate()
If Source = "Contracted Operator/Agent" Then
AgentOperator.enabled = True
Else
AgentOperator.enabled = False
End If
End Sub

After I have done this, the AgentOperator combo does become disabled, but it is also disabled when "Contracted Operator/Agent" is chosen in the Source Combo. I thought the code was supposed to leave the "Contracted Operator/Agent" enabled??? Why is it not doing this? Why is it disabling with all choices?

I would be really grateful if someone can be kind enough to help me. I feel so stupid not being able to handle this one on my own. It really is hard to over the years have become somewhat of an Excel professional, but now I am a complete novice....

Thank you so much in advance!!!
 
Try this code:

Private Sub Source_AfterUpdate()
If Me.Source = "Contracted Operator/Agent" Then
Me.AgentOperator.enabled = True
Else
Me.AgentOperator.enabled = False
End If
End Sub
 
Are the combo boxes Bound or UnBound?

If they are unbound then your code will work fine. If they are bound then you would have to have code in the on current event of the form to enable or disable the second combo depending on what the first combo had stored in the table.

If they are bound either post a copy of you db and someone will have a look for your or post back and I will do a sample of bound combo's

Have a look at my sample it is based on your code and works fine. (Form 2)
 

Attachments

Edtab, thank you so much for trying, but I have already tried that and it does not work.
 
ansentry said:
Are the combo boxes Bound or UnBound?

If they are unbound then your code will work fine. If they are bound then you would have to have code in the on current event of the form to enable or disable the second combo depending on what the first combo had stored in the table.

If they are bound either post a copy of you db and someone will have a look for your or post back and I will do a sample of bound combo's

Have a look at my sample it is based on your code and works fine. (Form 2)

Thanks for the examples... that is exactly how I want it to work in my form! I tried to find out if my combos are bound or unbound and I guess they are bound. I do not not know anything about bound except that I guess it means that the label is stuck to the combo(?) I did try to change the label to just being a text box to make my combos unbound, but what happened then is that the labels simply disappeared and were replaced by numers (the ID number, maybe?).

I am sorry that I am so terribly fresh at this but really appreciate a lot that you are taking the time to help me with something you have helped others with countless times before.

I attach my db here. Also, in the proces of trying to correct things, you will see that I lost the choices in the Status combo... I have no idea why! I have no idea how to get the table to re-connect again with it. Do I have to delete the whole form and start designing from the beginning?

I am starting to regret that I ventured on the Access path, because I can just imagine the problems I will have once I start creating the various reports. However, with people so willing AND quick to offer their assistance there might be hope! Thank you so much for any help you might be able to provide with my oh so very simple Access db (simple, at least for now...)
 

Attachments

Here is your db back and working.

Your combos were bound (that is they had a control source)

When you want to refer to data in a combo you must remember that column "counting" starts at 0. So you ID is column 0 and Source is 1.

I also suggest that you change the way you name fields etc.With the source table it should be tblSource the combo should be cboSource and text boxes should be e.g. txtTotalGuests (instead of Total Quest).

Also when you are naming fields in a table don't leave gaps Total Quests should be TotalGuests.

In my humble opinion.
 
Last edited:
Thank you so much for your assistance, John! I really appreciate it!!! And, in regards to your "humble opinion" why should it be humble? It is sound advice to a novice, so your opinion is taken as a good advice and I will change my fields and naming accordingly.
 
Last edited:
Just one question, whne I loose the data in a combo, I have no idea why... how do I re-connect again? Do I have to delete the whole form and start designing from the beginning?
I don't know what you mean about loosing the data, does the database I sent you back work OK?

I tested it and it appears to be fine, it saves the data to the table and I get no errors. The combo's appear fine.

If the one I sent you is working then do this;

Open up your orginal database and go to forms and change the name of the form Reservation Details to Reservation Details_OLD.

Now import from my fixed database (Copy of European Markets Activity141006) the form Reservation Details. This will mean that you also imported the code that I fixed, and the name changes to the combos that I made. With "My copy" of the form all should work fine.

If you are still having problems post back.
 
Works perfect now! Thanks a lot! I am sure I will be back once progressing. The funny thing is that this reminds me of when I got to learn excel... I have decided what end product I want, but as I go a long and learn more and more what the possibilities are, I do not get closer to the end product, because I keep adding things and features. Makes it all fun again. As long as there are people like you willing to help when there is a major obstacle!!! Thank you!
 
Glad we got it to work,good luck with your database.
 

Users who are viewing this thread

Back
Top Bottom