calculate date

  • Thread starter enrico via AccessMonster.com
  • Start date
E

enrico via AccessMonster.com

can you calculate date? my forms consists of two date textboxes where the
user will input the start and end date he/she wishes to return a desired
result from my form. i want to create a textbox where if the days between the
2 dates is more than 30 it will show a specific word(e.g. "month")
 
N

NevilleT

Hi Enrico

If I understand what you want to do, the user enters dates in two text
boxes, then you calculate the difference. If it is more than 30 days, it
displays the word "Month" in the third text box. If less than a month, it
displays the number of days.

You can use the BeforeUpdate for the two text boxes (start and end) to
create the third (difference)

Private Sub txtStart_BeforeUpdate(Cancel As Integer)
Dim lngDiff As Long
If Not IsNull(Me.txtStart) And Not IsNull(Me.txtEnd) Then
lngDiff = DateDiff("d", Me.txtStart, Me.txtEnd)
If lngDiff > 30 Then
Me.txtDiff = "Month"
Else
Me.txtDiff = lngDiff
End If
End If
End Sub

Neville Turbit
www.projectperfect.com.au
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top