Visual Basic question for if then statement

  • Thread starter Thread starter Keri
  • Start date Start date
K

Keri

Hi I am trying to write a code using the if then statment. I am tracking
mileage costs for cars but I need to add a statement if the car was only used
for a number of days to get it charge the monthly fee right. Here is the
code that I'm using

Private Sub Monthly_Rental_BeforeUpdate(Cancel As Integer)
If Days < 30 Then
If IsNull(Me.Day_Rates) Then
Me.Day_Rates = Monnthly_Rental / Days
End If
End If
End Sub

Its not working proberly and I not sure what I'm doing wrong. Thank you.
 
Hi Keri

I'm not quite clear about what you are trying to achieve, and why it is not
working.

However, if you want to calculate a pro-rata rate for Days as a fraction of
the whole month, you need something like this:

Me.Day_Rates = Monthly_Rental * Days / 30
 
LOL! Yes, I noticed that, Linq, but the possibility was too much to
contemplate <g>
 
Hi Linq and Graham,

Thank you very much for your response. I was able to get the epression
bulider to work with the function that Graham gave me but the code didn't
work. I tried it before and after update. I guess I need to take a detailed
class on Visual Basic. I really like the programming but I get fustrated
when what I think would be simple doesn't work the way it should.

Keri
 
Back
Top