StreamLine VBA Code

Coldsteel

Registered User.
Local time
Today, 17:10
Joined
Feb 23, 2009
Messages
73
Hello all,

Is there a way to improve my code? Here is my code:

Private Sub STATUS_AfterUpdate()
If Me.STATUS = "CLOSED - INVAILD" Then
Me.TimeStamp = Date
End If
If Me.STATUS = "CLOSED - FUNDED" Then
Me.TimeStamp = Date
End If
If Me.STATUS = "CLOSED - DENIED" Then
Me.TimeStamp = Date
End If
If Me.STATUS = "CLOSED - INVAILD" Then
Me.STARPOINTS = 0
End If
If Me.STATUS = "CLOSED - NEVER FUNDED" Then
Me.TimeStamp = Date
End If

End Sub

Thanks,
Mike
 
you can use OR in there
Code:
If Me.STATUS = "CLOSED - INVAILD" OR Me.STATUS = "CLOSED - FUNDED" OR etc... Then
me.timestamp=date
elseIf Me.STATUS = "CLOSED - INVAILD" Then
Me.STARPOINTS = 0
else
End If
 
Last edited:
How about SELECT CASE?

Code:
Private Sub STATUS_AfterUpdate()
   Select Case Me.STATUS
      Case "CLOSED - INVAILD", "CLOSED - FUNDED" , "CLOSED - DENIED", "CLOSED - NEVER FUNDED"
            Me.TimeStamp = Date
      Case "CLOSED - INVAILD" 
            Me.STARPOINTS = 0
   End Select
End Sub
 
watch your typo

invaild or invalid

for reasons like this, developers often use numeric values for combo boxes, with the actual text taken from a look up table
 

Users who are viewing this thread

Back
Top Bottom