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.Code:Public Function CDate2Julian(ReqDate As Date) As String CDate2Julian = Format(ReqDate - DateSerial(Year(ReqDate) - 1, 12, 31), "000") End Function
TestingCode: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
in immediate mode returns the correct date for 8-11-2009 which is 9223.Code:Print Year(DATE()) Mod 100 & CDate2Julian(DATE())
Using
in immediate mode for the same date above displays 2223 in immediate mode in which the first digit should be a 9.Code:Forms!RequestForm!JulianDate = CDate2Julian(Year(Forms!RequestForm!ReqDate)) Mod 10 & CDate2Julian(Forms!RequestForm!ReqDate)
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
Last edited by drewship; 08-17-2009 at 11:46 AM.
I have a couple of questions.
First off is this form open?
Do you want this date stored in a table, or is it a one time date?
My answers change based on these questions.
However I do have some answers.
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
I am gonna save you some time and try and answer it anyway.
Enter the following in the "Control Source" field in the properties of your field in your form called : JulianDate
I tested this off a date field that I have in my database.Code:=Year([ReqDate]) Mod 10 & Format([ReqDate]-DateSerial(Year([ReqDate])-1,12,31),"000")
You shouldn't need any vba for this, if this is what you were thinking.
Hope this helps,
Dan
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
Thanks for the code Dan. I will answer your questions then try the code.
First off is this form open? Yes. The user has the form open selecting items. Once the user enters the date, I want the julian date to be calculated.
Do you want this date stored in a table, or is it a one time date? I need this stored in a table as part of the key to identify individual orders.
Andrew
Last edited by drewship; 08-14-2009 at 09:39 AM.
The code works to display the julian on the form and I have added a text box that will be hidden and will save the value to the table via the control source. There may be a better way but I am still learning.
Thanks,
Andrew
Glad I could help, please mark your post as solved if you are satisfied with the answer.
Thanks,
Dan
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks