|
-
May 4th, 2000, 12:29 AM
#1
Thread Starter
Addicted Member
I have a comboBox with the values 1 - 10. If the user selects 5 I want to prompt message.
if combobox.value = 5 then
msgbox "You have selected 5"
end if
I am sure this is easy I just can't figure it out. I have tried onChange, Validate, but these seem to also occur when you move from one record to the next and the value in the combo box changes. If I place code in the on click, it executes prior to the user actually selecting a value on the drop down. I only want it to execute when they have finished selecting the value. The best thing I have found so far is to do it on lost focus but that requires them to leave the field and go to another.
I hope I have made sense.
Thanks in advance
-
May 4th, 2000, 12:32 AM
#2
Thread Starter
Addicted Member
I just used a datalist and it works fine. Thanks anyway
-
May 4th, 2000, 12:34 AM
#3
Fanatic Member
I'm pretty sure (not 100%) that I usually use the on_click event. I know you said it executes before you select the value, but I'm certain thats how I've done it in the project I'm doing now. I can't check till tomorrow morning as I'm at home now, but if you don't have an answer by then I'll let you know.
-
May 4th, 2000, 01:19 AM
#4
If you want to find out what utem is particularly selected, then you can do something like this:
Code:
If Combo1.List(Combo1.ListIndex) = "Your Value" Then
'Do your stuff here...
End If
-
May 5th, 2000, 12:35 AM
#5
Thread Starter
Addicted Member
Thanks Serge. I am able to see what is currently in the field by using the .Fields("MyField") criteria.
Stevie: Let me know what it does on yours?? I started with VB4, then upgraded to VB5, and now I placed a new version of VB6 on same system. Maybe some corruption????
The problem is that when I click the down arrow to the right of the ComboBox it executes the Click Function before I can select from list. However, when I create a datalist box and click the right arrow it doesn't execute. It only executes when I click on an Item. I would much preffer a combo box but it doesn't react the same??????
-
May 5th, 2000, 02:04 AM
#6
Fanatic Member
I'm using VB6 and I'm definately using the click event. It doesn't execute when the list drops down, it executes when an item is selected by clicking on it.
I didn't have any previous versions of VB on my system so I don't know if that has any bearing on it. Seems weird to me that it doesn't work that way on yours.
-
May 5th, 2000, 03:29 AM
#7
In the comboboc's click even put...
Code:
If Combo1.Text = "5" then MsgBox("you chose 5")
-
May 5th, 2000, 03:42 AM
#8
Thread Starter
Addicted Member
Here is my problem. I want a button to appear next to the combobox when a person selects 5 or if the value is equal to 5 when they move through records. It works fine when I move from one record to another. However, when someone changes the value from say a 1 to a 5, I can not determine it because I can not place code in the onClick function because that takes place prior to them selecting the value. I can not place the IF...Then statment in this spot because once again it would equal 2 not 5 because it is happening before the user can select a value.
One thing I am seeing when I first bring up a new project in VB6 I am choosing the ADO common controls 6.0 and I have to make a reference to them.
Stevie is saying that it works for him so It must be something with my version.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|