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

can you stop a combobox from accepting certain choices?

Status
Not open for further replies.

etislost

Technical User
Nov 23, 2003
19
0
0
US
I have three comboboxes. The first contains Vbasic code which determines which of the other two boxes is visible depending upon the choice made in the first combobox. This is all well and good.

My first problem is this...
It is currently possible to not click in the first box, yet still make a choice in the second/third box and save it as an entry. This is no bueno! Is there a way to eliminate this problem? If so, please elaborate.

My second problem is this...
The value chosen in either the second or third combobox shows up in the table in the fields bound to those boxes. In otherwords, how do I get the proper field to have an entry and get the other to be blank?

Thanks,
Steve P.
 
[tt]
Hi, Steve:

Sometimes my solutions get a little complicated, but I'll try to answer your first question as simply as possible.

You can hide the 2nd and 3rd combo boxes until you a choice is made in the 1st.

In the property sheet for the 2nd and 3rd combo boxes, format, Visible, "No".

In the AfterUpdate event of the 1st combo box:

If Me.cboOne Not IsNull Then
Me.cboTwo.Visible = True
End If


In the AfterUpdate event of the 2nd combo box:

If Me.cboTwo Not IsNull Then
Me.cboThree.Visible = True
End If


I'm not sure about the "Not IsNull" and I'm not at the computer with Access on it, but I think that will work. Anyway, the logic should be clear.

2nd problem: In the On CurrentEvent in the property sheet for the form, enter

If Me.cboTwo Not IsNull Then
Me.cboThree = Null
End If

If Me.cboThree Not IsNull Then
Me.cboTwo = Null
End if


Another, and perhaps better way, is to keep the third cbo not visible if an entry is made in the second cbo.

I am always ready to be corrected by those who know more than I do, and the Lord knows, there are a lot of them!

Good luck,[/tt]




[glasses][tt]Gus Brunston - Access2000(DAO)
Skill level based on 1-10: 7
Webmaster: www.rentdex.com[/tt]
 
[tt]

Ah....!

I think the syntax is:

If Not IsNull(Me.cboWhatever) Then
. . . . . .
End If
. . . . . .


Let's see...is that four mistakes or one? I'm in danger of having to lower my 1-10 rank to 6 from 7!

Sorry.[/tt]



[glasses][tt]Gus Brunston - Access2000(DAO)
Skill level based on 1-10: 7
Webmaster: www.rentdex.com[/tt]
 
[tt]
I read your questions again. You say, "It is currently possible to not click in the first box, yet still make a choice in the second/third box and save it as an entry"

Since you indicated you have code that will make the 2nd and/or 3rd boxes invisible, why not keep them both invisible until you've got data in the first?

Is a puzzlement...[/tt]

[glasses][tt]Gus Brunston - Access2000(DAO)
Skill level based on 1-10: 7
Webmaster: www.rentdex.com[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top