Hello all,
I have played around with many variations and this what I have come up with so far. The below code as you can see is a function and I have it in a module called JulianDateConvert since I have not been able to combine it with the Sub (probably cant combine them).
The below code should call the function 'CDate2Julian' above, retrieve the user entered date from the text box called ReqDate and place the converted date into the JulianDate text box.
Testing
in immediate mode returns the correct date for 8-11-2009 which is 9223.
Using
in immediate mode for the same date above displays 2223 in immediate mode in which the first digit should be a 9.
Can someone please assist me in getting the correct julian date to display on the form either after the date is entered on the form or when a button is pressed.
Thanks,
Andrew
I have played around with many variations and this what I have come up with so far. The below code as you can see is a function and I have it in a module called JulianDateConvert since I have not been able to combine it with the Sub (probably cant combine them).
Code:
Public Function CDate2Julian(ReqDate As Date) As String
CDate2Julian = Format(ReqDate - DateSerial(Year(ReqDate) - 1, 12, 31), "000")
End Function
The below code should call the function 'CDate2Julian' above, retrieve the user entered date from the text box called ReqDate and place the converted date into the JulianDate text box.
Code:
Private Sub JulianDate_AfterUpdate()
'RequestForm is the name of the form, JulianDate is the name of the cell to display the julian date, 'and ReqDate is the date entered on the form by the user
Forms!RequestForm!JulianDate = CDate2Julian(Year(Forms!RequestForm!ReqDate)) Mod 10 & CDate2Julian(Forms!RequestForm!ReqDate)
End Sub
Testing
Code:
Print Year(DATE()) Mod 100 & CDate2Julian(DATE())
in immediate mode returns the correct date for 8-11-2009 which is 9223.
Using
Code:
Forms!RequestForm!JulianDate = CDate2Julian(Year(Forms!RequestForm!ReqDate)) Mod 10 & CDate2Julian(Forms!RequestForm!ReqDate)
in immediate mode for the same date above displays 2223 in immediate mode in which the first digit should be a 9.
Can someone please assist me in getting the correct julian date to display on the form either after the date is entered on the form or when a button is pressed.
Thanks,
Andrew