Combo box with null value

D

Don

I have a form whereby the user can click a command button to display a combo
box and a select value. My question is if the user has mistakenly clicked the
button and tabbed away from the combo without selecting a value, how would I
go about resetting the button and its' combobox. That is, the combo goes
invisible again and its' button is ready to be clicked again.

TIA.............
 
A

Al Campagna

Don,

When the button (ex. cmdShowCombo) is clicked, use GoToControl to go to
force the user to the combo (ex. cboCombo1).

Private Sub cmdShowCombo_Click()
cboCombo1.Visible=True
DoCmd.GoToControl "cboCombo1"
End Sub

After that, the use the OnExit of the combo to...

Private Sub cboCombo1_Exit(Cancel as Integer)
If Isnull(cboCombo1) Then
DoCmd.GoToControl "cmdShowCombo"
cboCombo1.Visible = False
End if
End Sub

The user could then click the button again... if entry is still
required... or just go anywhere on the form from there.

Although, I don't understand why you're using a button to show the
combo. I would think the combo would show...if some condition on the form
exists... that makes that combo entry necessary. That's a more "usual"
setup, and would automate the whole process.
And, I would not use the code above if the combo "must" have an entry.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
D

Don

Thanks for that Al, excactly what I was looking for.
FYI, as part of the design brief on this particular form, there are three
command buttons that when clicked will display a corresponding combo box. All
cbo's are invisible until a relevant button is clicked, values are selected,
or as in this post, not... and more concurrent fields are filled in. I have a
Save button at the footer as a confirmation method for the user and to then
reset the command buttons and combos.
Again, thanks for the advice.
 
A

Al Campagna

Don,
My question would be... why are you hiding those combos?
Do some specific records require entry in one (or more) combo entries?
If so what logic decides that?
(ex. If field XYZ = "ABC" then show Combo2...)
or
(If XYZ = "ABC" hide Combo1 and Combo3...)

Just suggesting that the show/hide should be logic driven... not button
driven.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Setting a combo box value 8
combo box 1
Combo Box Requering 2
changing Combo Box dispalyed value 1
Combo Box 3
combo box data type 1
Choose a value from a combo box based on a text box 0
Combo Box Help 7

Top