Run Code on combo selection (1 Viewer)

spacepro

Registered User.
Local time
Today, 23:26
Joined
Jan 13, 2003
Messages
715
Hi All,

Just a quick one! I have a combo ona form which is unbound, with a list of functions. When the user selects an entry from the list, as soon as the selection as been made I want to run the code from a module. Just don't know what event or if it is possible. I trying to do this without using a cmd button.

So on selection run code:
Code:
call function1

Many Thanks

Andy
 

Mile-O

Back once again...
Local time
Today, 23:26
Joined
Dec 10, 2002
Messages
11,316
AfterUpdate event.

If you don't want it to run if no value is selected:

Code:
Private Sub MyCombo_AfterUpdate()
    If IsNull(Me.MyCombo) Then Exit Sub
    Call Function1
End Sub

If you are not getting a return value then you are better to call a Sub rather than a Function. ;)
 

spacepro

Registered User.
Local time
Today, 23:26
Joined
Jan 13, 2003
Messages
715
Hi Mile,

Thanks for that. I already tried the afterupdate but what i did by mistake was use 1,2,3 etc instead of the value in the list in the selct case statement.

For example:
Code:
select case me.combo
case 1
call function1
case 2
call function2

and it should have been
Code:
select case me.combo
case is = "Open Spreadsheet"
call function1
case is = "Import Data"
call function2


Cheers Mile,
Hope you are keeping well.....

Andy ;)
 

R6Flyer

Yamaha hooligan
Local time
Today, 23:26
Joined
Nov 21, 2003
Messages
95
Rich said:
preferable to keeping quiet eh ;)

Talking about Mile-O...

I notice that he has changed his avatar again. I much preferred his old one - the one with the picture of his daughter. :D
 

Users who are viewing this thread

Top Bottom