StreamLine VBA Code (1 Viewer)

Coldsteel

Registered User.
Local time
Today, 02:27
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
 

rainman89

I cant find the any key..
Local time
Today, 03:27
Joined
Feb 12, 2007
Messages
3,015
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:

SOS

Registered Lunatic
Local time
Today, 00:27
Joined
Aug 27, 2008
Messages
3,517
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
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:27
Joined
Sep 12, 2006
Messages
15,672
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

Top Bottom