How do I display module results in a form text box

drewship

New member
Local time
Today, 09:35
Joined
Aug 13, 2009
Messages
2
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).

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
 
posted wrong stuff...

It seems you are converting only mod 10 command... You should Mod 10 the date not the results of your function.

Forms!RequestForm!JulianDate = Year(Forms!RequestForm!ReqDate) Mod 10 & CDate2Julian(Forms!RequestForm!ReqDate)
 
Last edited:
Thanks. Someone else actually provided

Code:
=Year([ReqDate]) Mod 10 & Format([ReqDate]-DateSerial(Year([ReqDate])-1,12,31),"000")

which I placed in the control source of the text box and it works fine.
 

Users who are viewing this thread

Back
Top Bottom