none
VBA If statement RRS feed

  • Question

  •  I'm looking for the code to do an if statement used two conditions.

     I have used the code below, but it does not show the result and neither error message.

    Public Sub PaymentDelay()

    If Me.txtDueDate >= Me.txtTodayDate Then
        Me.txtOverDue = "OK"
    ElseIf Me.txtDueDate < Me.txtTodayDate Then
        Me.txtTodayDate = Me.txtTodayDate - Me.txtDueDate
    End If

    End Sub

    Private Sub txtOverDue_AfterUpdate()
    Call PaymentDelay
    End Sub

    Friday, December 15, 2017 9:37 PM

All replies

  • Hi,

    (1) You need to provide Data Type of Me.txtTodayDate and Me.txtDueDate.
    (2) And code could be this:

    If Me.txtDueDate >= Me.txtTodayDate Then
        Me.txtOverDue = "OK"
    ' ---ElseIf Me.txtDueDate < Me.txtTodayDate Then <--- not needed
    Else
        Me.txtTodayDate = Me.txtTodayDate - Me.txtDueDate
    End If

    Regards,



    Ashidacchi

    Friday, December 15, 2017 11:59 PM