using combobox for drop down menu?

G

Geoff Cox

Hello,

I am starting to play around with drop down menus using comboboxes.

The code below works in that when the mouse moves over the image
behind the combobox, the box is populated with the various options.

A couple of questions.

Is it possible to bring the focus back to the slide once the correct
answer has been selected?

How do I ensure that the box is empty when the presentation is run? At
the moment sometimes it is empty, sometimes there is a 0 or 1 in the
box.

Thanks

Geoff

PS any source of help in using comboboxes? Books or the net?


Private Sub Initialize()
If ComboBox1.ListCount = 4 Then GoTo Check
ComboBox1.AddItem "Select"
ComboBox1.AddItem "Red"
ComboBox1.AddItem "Green"
ComboBox1.AddItem "Blue"

Check:
ComboBox1.Style = fmStyleDropDownList
ComboBox1.BoundColumn = 0
ComboBox1.ListIndex = 0

End Sub

Private Sub ComboBox1_Click()
Select Case ComboBox1.Value
Case 0
Label1.Caption = "What's your Answer?"
Case 1
Label1.Caption = "No, try again."
Case 2
Label1.Caption = "No, try again."
Case 3
Label1.Caption = "Well done, this is the correct answer."

End Select
End Sub


Sub object_mouse_over()

Initialize

End Sub
 
S

Steve Rindsberg

How do I ensure that the box is empty when the presentation is run? At
the moment sometimes it is empty, sometimes there is a 0 or 1 in the
box.

If you've worked out a way of getting code to run at startup, use the .Clear
method on the combobox.
PS any source of help in using comboboxes? Books or the net?

Help in the VBA IDE has a good bit.
For help with specific properties, rightclick the combobox, choose Properties.
Click on the property you want to know about then press F1

After doing that, you can click on Applies To in the help screen, choose
ComboBox to go to the combo box help screen.
 
G

Geoff Cox

If you've worked out a way of getting code to run at startup, use the .Clear
method on the combobox.

Steve,

Thanks for the above and for help ideas below.

Any idea re getting the focus from the CombBox to the slide?

Cheers

Geoff
 
S

Steve Rindsberg

I guess I'm not clear on what the problem is. Normally to change the focus, the
user would click on the slide.
 
G

Geoff Cox

I guess I'm not clear on what the problem is. Normally to change the focus, the
user would click on the slide.

Steve,

I see that but just wondered if it was possible to move the focus back
to the slide (using VBA) when say the user presses the enter key
whilst in the TextBox Control?

Perhaps asking too much?!

Cheers

Geoff
 
S

Steve Rindsberg

Steve,

I see that but just wondered if it was possible to move the focus back
to the slide (using VBA) when say the user presses the enter key
whilst in the TextBox Control?

Perhaps asking too much?!

I don't know ... I don't quite understand the problem, hence the confusion.
 
G

Geoff Cox

I don't know ... I don't quite understand the problem, hence the confusion.

Steve,

Apologies - I have muddled ComboBox and TextBox situations above but
the "problem" is the same.

A user will perhaps be wondering why they cannot move to the next
slide by pressing the enter key. I realise that if they click on the
slide to put the focus there, then the next enter key press will move
them on to the next slide.

Just wondered whether there was a way to use VBA to move the focus
back to the slide once the correct answer has been selected using a
ComboBox or when say the enter key is pressed when typing into a
TextBox....

Cheers

Geoff
 
B

Bill Foley

Not really a fix, but what I have done in the past is put a navigation
button that goes to the next slide and typed "Double-click" as the text on
the button. First click takes the focus and the next one does the action.
Sorry for the rudimentary method, but I don't know of any VBA method to
return focus either.
 
S

Steve Rindsberg

Apologies - I have muddled ComboBox and TextBox situations above but
the "problem" is the same.

A user will perhaps be wondering why they cannot move to the next
slide by pressing the enter key. I realise that if they click on the
slide to put the focus there, then the next enter key press will move
them on to the next slide.

Aha, now I get it. I don't have an answer but let me think about it ...
 
G

Geoff Cox

Not really a fix, but what I have done in the past is put a navigation
button that goes to the next slide and typed "Double-click" as the text on
the button. First click takes the focus and the next one does the action.
Sorry for the rudimentary method, but I don't know of any VBA method to
return focus either.

Thanks Bill - that does the trick if Steve cannot come up with any VBA
inspiration!

Cheers

Geoff
 

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

A ComboBox question 6
ComboBox with VBA 0
list box remove item by combobox 4
excel sheet with control combobox 3
How to Add items to a ComboBox list 11
ComboBox Help 1
VBA Macros 5
User From Combo box help 1

Top