Drop Down Lists

thesuggs76

Board Regular
Joined
Nov 15, 2006
Messages
247
I hope that you can help.

In my Acccess Database the form has a couple of drop down lists. The second list is dependent on the first. SO the second list should only be selected if the answer to the first is "Acceptable". There are 3 choices in the first, if the other two are choosn the second drop down list should be left blank

The second drop down list has 4 options and i also want that as soon as "Acceptable" in the first, it automatically chooses "Waiting" from the list. Once the outcome has been reached it can be changed with one of the other 3 choices

Any help would be much appreciated :)
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi

Attach the following code to the after update event of the first combo box :

Code:
Private Sub Combo1_AfterUpdate()

If Me.Combo1.Value = "Acceptable" Then
    Me.Combo2.Enabled = True
    Me.Combo2.Value = "Waiting"
Else
    Me.Combo2.Enabled = False
    Me.Combo2.Value = ""
End If

End Sub

Make sure you use the correct combo box names where I have used Combo1 and Combo2.

Just ask if you aren't sure how to use this code.

Andrew
 
Upvote 0
Hi
Thanks for your help, i got the code to work. However i have noticed that whenever i go out of the form and then back in it stops working. i am having to actually select one of the drop down lists again for the code to kick in.
is there anywy for this to be done automatically
 
Upvote 0
Hi

Copy the code into the forms 'On Current' event. You may want to remove the line :

Me.Combo2.Value = "Waiting"

from the 'On Current' version of the code. This code kicks in when you either navigate between records or open the form.

Sorry I forgot to mention it previously but when one uses events in combo boxes on form, it is usually a good idea to use the same/similar code in the forms 'On Current' event.

Andrew
 
Upvote 0
Thanks for the help, it is nearly waorking like a charm. One last thing and this is probably the easiest one, but i am stupid.
The database i applied it to already had about 300 records, and in the second combo box it is only showing a blank field instead of what was previously there. is there any way of bringing these records back without having to do it manually.
:unsure:
 
Upvote 0
D'oh!

I presume the data is missing from the table? If not, then you're ok - it is still there but simply not showing. Let me know if this is the case.

If not, have you got a copy of the database? If you have a copy then you should be able to copy/append the data across - if not, you will need to manually re-create it. Before you re-create all of the missing data and then potentially lose it all again - is there anything in particular that is making the data disappear? Is it the line :

Me.Combo2.Value = ""

in the 'On Current' event? If so, remove that line from the 'On Current' event code. Did you remove the other line like I mentioned?

Andrew
{I edited my response because I thought it didn't make sense, then I removed my edit because it did actually make sense! :oops: }
 
Upvote 0
Hi

Is the 2nd combo box bound to the field in question? We have to be careful to not over-write any data here (I thought we already had!). Did you try the suggestion in my previous post to remove the {Me.Combo2.Value = ""} line from the 'On Current' event?

Andrew
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top