Solved Combobox - After Update with multiple If..Then Statements (1 Viewer)

hbrehmer

Member
Local time
Yesterday, 19:11
Joined
Jan 10, 2020
Messages
78
Hi All,
I have a combobox that depending on the user selection, I need a number to be assigned. I am trying to automate status changes of a production ticket. This is my code, but it doesn't work correctly:

Private Sub Combo38_AfterUpdate()
If Me.Combo38 = 4 Then
Me.TKTStatusID = 3
End If
If Me.Combo38 = 1 Or 2 Or 5 Or 6 Then
Me.TKTStatusID = 4
Else
Me.TKTStatusID = 2
End If
End Sub

Help, please! All selections return a "4". Urgh!

Heidi
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:11
Joined
Oct 29, 2018
Messages
21,491
Hi. Try using a Select Case statement instead.
 

hbrehmer

Member
Local time
Yesterday, 19:11
Joined
Jan 10, 2020
Messages
78
Can you give me an example of a Select Case Statement? I'm still learning how to code. Even bought VBA Coding for Dummies! :)

Is the Select Case for the field I want changed? (ie Me.TKTStatusID ?) Or is it tied to the combobox? I am a bit confused.
 
Last edited:

moke123

AWF VIP
Local time
Yesterday, 22:11
Joined
Jan 11, 2013
Messages
3,927
select case Me.Combo38

Case 1,2,5,6
Me.TKTStatusID = 4
Case 3
Me.TKTStatusID = 3
case 4
Me.TKTStatusID = 2
End select
 

hbrehmer

Member
Local time
Yesterday, 19:11
Joined
Jan 10, 2020
Messages
78
Thank you so much for the help! I am starting to catch on to this programming stuff. There are just so many options, I'm not always sure which to use.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:11
Joined
Oct 29, 2018
Messages
21,491
Thank you so much for the help! I am starting to catch on to this programming stuff. There are just so many options, I'm not always sure which to use.
Hi. We're all happy to assist. Good luck with your project.
 

Users who are viewing this thread

Top Bottom