Date Calculation Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm creating a form "FrmSales" from a query to input sales, and need the
proper code (and where to put it in the form field: Sales Expiration Date
[SaleExpires] Properties) . The date value is to be calculated from the
Sale Date [SaleDate] using [BillingID]: 1=Annually, 2=Quarterly, 3=Monthly.
In addition, I want to add 3 days to each calculation. I know this is
pretty basic, but I'm just learning and this is over my head. Any help would
be greatly appreciated.
 
In the Current Event of [SaleExpires]

Dim strInterval as String

If IsNull(Me!SaleExpires) then
Select Case Me!BillingID
Case is = 1
strInterval = "y"
Case is = 2
strInterval = "q"
Case is = 3
strInterval = "m"
End Select
Me!SaleExpires = dateadd("d",3,dateadd(strInterval,1,date))
 
Thanks so much.
--
Tom


Klatuu said:
In the Current Event of [SaleExpires]

Dim strInterval as String

If IsNull(Me!SaleExpires) then
Select Case Me!BillingID
Case is = 1
strInterval = "y"
Case is = 2
strInterval = "q"
Case is = 3
strInterval = "m"
End Select
Me!SaleExpires = dateadd("d",3,dateadd(strInterval,1,date))

Tom U said:
I'm creating a form "FrmSales" from a query to input sales, and need the
proper code (and where to put it in the form field: Sales Expiration Date
[SaleExpires] Properties) . The date value is to be calculated from the
Sale Date [SaleDate] using [BillingID]: 1=Annually, 2=Quarterly, 3=Monthly.
In addition, I want to add 3 days to each calculation. I know this is
pretty basic, but I'm just learning and this is over my head. Any help would
be greatly appreciated.
 
Sorry to bother you again, but when I run the form I get a bug errer on the
line:


Me!SaleExpires = DateAdd("d", 3, DateAdd(strInterval, 1, Date))


I added End If prior to End Sub, but I don't know what else is wrong. Can
you help?

--
Tom


Klatuu said:
In the Current Event of [SaleExpires]

Dim strInterval as String

If IsNull(Me!SaleExpires) then
Select Case Me!BillingID
Case is = 1
strInterval = "y"
Case is = 2
strInterval = "q"
Case is = 3
strInterval = "m"
End Select
Me!SaleExpires = dateadd("d",3,dateadd(strInterval,1,date))

Tom U said:
I'm creating a form "FrmSales" from a query to input sales, and need the
proper code (and where to put it in the form field: Sales Expiration Date
[SaleExpires] Properties) . The date value is to be calculated from the
Sale Date [SaleDate] using [BillingID]: 1=Annually, 2=Quarterly, 3=Monthly.
In addition, I want to add 3 days to each calculation. I know this is
pretty basic, but I'm just learning and this is over my head. Any help would
be greatly appreciated.
 
Back
Top