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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Boxes + Clearing Entry 1

Status
Not open for further replies.

sk1hotpepr

Technical User
Jul 11, 2003
63
US
This is probably an easy question...
I have two combo boxes linked together - the first one chooses the state, the second then chooses a county. What I want to do is when the choice in ComboBox1 is picked, clear any current value in ComboBox2 so that I can pick from a list fresh. Right now if I change my state value, the second combo box stays the same. Any help would be much appreciated!

Thanks!
 
You may try something like this in the ComboxBox1 AfterUpdate event procedure:
Me!ComboBox2.Requery

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I already had that in my code, but it doesn't clear any current entry in the second combo box. If I choose a different state, the second combo box keeps the old value in view but changes the list that I can choose from. I want to clear out the entry so that it's blank when I go to choose another county. I hope that makes sense [ponytails2]. Thanks!
 
Me!ComboBox2.Requery
Me!ComboBox2.Value = Null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
When I try to add the Me!ComboBox2.Value=Null I get the error: Run-time error '3162' You tried to assign the Null value to a variable that is not a Variant data type.

I'm guessing that's because I have the Combo Box set to "Limit to List" as yes?

I don't want users to be able to add anything to the combo box...I'm not sure how else to set it.
 
I spoke too soon - this seems to work...

Private Sub cmbState_Change()
Me.cmbSD.Requery
Me.cmbSD.SetFocus
Me.cmbSD.Text = ""
End Sub

Thanks for your help PHV, you got me in the right direction!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top