Date Problem

Alan R

Registered User.
Local time
Today, 19:30
Joined
Sep 11, 2006
Messages
70
Hi,

I have moved this thread from Forms to here since i think it is better suited here.

Within my database i have a requirement to produce a number of invoice type reports. However because my Financial Year goes from 1 November to 31 October, so an invoice produced today - 15 November would have an identifier of 'Invoice number - 06/07' whereas one produced on the 31st October would be 'Invoice Number - 05/06'.

I have produced an OnClick Event which is included below for a button which will update a bound text box, this date is then picked up when i produce invoices:

Private Sub Command9_Click()
Dim mth, yr, yrplus As Integer
mth = Format(Date, "m")
yr = Format(Date, "yy")
If mth > 10 Then
yrplus = yr + 1
Me.CurrentYear = yr & "/" & "0" & yrplus
Else
yrplus = yr - 1
Me.CurrentYear = "0" & yrplus & "/" & yr
End If
End Sub

It is on a button since there are a number of housekeeping tasks that need to be completed before the values are updated.

Dependent on when in the normal year we are in the procedure adds or subtracts a year from the current year. However, i can't get the procedure to display the Yr+1 or Yr-1 values as 06, 07 etc, they are displayed as 6, 7 etc.

As a workround you will notice that i have included a "0" to force the correct value of 06, 07 etc. Whilst it works i am sure that there must be a correct / better way of achieving this but try i have i just cannot seem to get it . Does anybody have any tips / ideas? Is this the correct way to go about what i am trying to achieve?

Regards

Alan
 
Rich:
notice his first line:
I have moved this thread from Forms to here since i think it is better suited here.

Alan:
Can you try this:
Code:
Private Sub Command9_Click()
Dim mth, yr, yrplus As Integer
mth = Format(Date, "m")
yr = Format(Date, "yy")
If mth > 10 Then
yrplus = yr + 1
Me.CurrentYear = Format(yr,"00") & "/" & Format(yrplus,"00")
Else
yrplus = yr - 1
Me.CurrentYear = Format(yrplus,"00") & "/" & Format(yr,"00")
End If
End Sub
 
Bob,

Works a treat - many thanks.

Regards

Alan
 

Users who are viewing this thread

Back
Top Bottom