A family of Microsoft relational database management systems designed for ease of use.
Hi,
This is what I would use without knowing the full extent of your logic. Make sure you use comments in your code. Also, you can test your function by opening the immediate window (press Ctrl+G) and entering something like:
?GetCurrentRent(2, #1/1/2017#, 1234, 5)
Sorry about the lack of indenting in these replies.
Public Function GetCurrentRent(lngLeaseTypeFrame As Long, datLeaseStart As Date, _
dblRent As Double, dblReviewPct As Double) As Double
'put some comments here about the logic of your function
' This function is used to get the current rent based on the Lease Type Frame, Lease date, Rent, and Reveiw Percent
' There are 6 possible Lease Type Frames
' 1 -
' 2 -
' 3 -
Dim datToCompare As Date 'create a date variable to break apart expressions
Select Case lngLeaseTypeFrame
Case 1 'the meaning of 1 goes here like: "short term with renewal clause"
datToCompare = DateAdd("yyyy", 1, datLeaseStart) - 1
If datToCompare <= Date Then
GetCurrentRent = dblRent + dblRent \* dblReviewPct / 100
Else
GetCurrentRent = dblRent + dblRent \* dblReviewPct / 100
End If
Case 2 'the meaning of 2 goes here
Case 3 'the meaning of 3 goes here
Case 4 'the meaning of 4 goes here
Case 5 'the meaning of 5 goes here
Case 6 'the meaning of 6 goes here
Case Else 'pick up any missed values
GetCurrentRent = dblRent
End Select
End Function