cwess
Apr 11 2005, 08:53 PM
Im having a problem with this simple function...
I have a option group set up for 1, 2, 3 thats labled with (short, medium and long) term goals.
At the bottom of the same form I have a due date field. I have tried mixing and matching the dateadd function but with no avail. Im not real strong with vb but I assume Im going to have to end up with a 3 step if then statment???
chris
JayNoelOlimpo
Apr 11 2005, 09:38 PM
Have you tried ...
Select Case optGroup
Case 1
ControlNameHere = DateAdd("m",1,Date()) '***** May 12, 2005
Case 2
ControlNameHere = DateAdd("m",6,Date()) '***** October 12, 2005
Case 3
ControlNameHere = DateAdd("m",12,Date()) '***** April 12, 2006
End Select
'***** Hope this helps ....
cwess
Apr 11 2005, 09:50 PM
ok I think I understand..
Would you put this into vb code or right click and input it into the option value field in access?
thanks for you help
chris
JayNoelOlimpo
Apr 11 2005, 09:55 PM
Place it in AfterUpdate event module of an option group ...
Select the OptionGroup -- Event -- After Update -- Click on the [...] -- Code Builder ...
Copy and paste it ...
cwess
Apr 11 2005, 10:13 PM
ok, copied and pasted text, changed control names. I think it works....however the due date field at the bottom does not reflect the change when an option is pushed....Im not sure how to link the user selected button from the option group to the date field at the bottom.
chris
JayNoelOlimpo
Apr 11 2005, 10:25 PM
Could you post your code and the control name of each ...
ControlNameHere should be the due date ...
cwess
Apr 11 2005, 10:37 PM
This is the vb code, but I noticed its bound to "private sub frame102" (that dosnt sound right)
Also the text box at the bottom that holds the due date is called "Due Date"
I again appreciate your help
chris
Private Sub Frame102_AfterUpdate()
Select Case optGroup
Case 1
[due Date] = DateAdd("m", 3, Date) ' 3 month
Case 2
[due Date] = DateAdd("m", 6, Date) ' 6 month
Case 3
[due Date] = DateAdd("m", 12, Date) ' 12 month
End Select
End Sub
JayNoelOlimpo
Apr 11 2005, 10:56 PM
Change optGroup to Frame102 ...
R. Hicks
Apr 11 2005, 11:34 PM
Are you saving the date of the transaction in your table ???
If you are .. then you should not be trying to save this "due date" value in your table as it would violate the Normal Form ...
The due date can be calculated when needed, on demand, dynamically by using a expression.
You simply store the option group value and the transaction date to base the due date on .. then you dynamically calculate the due date when it is needed and not store it in a table ...
RDH
cwess
Apr 12 2005, 01:56 AM
Jay - That worked.....had the right idead just didnt know how to implement it.
thanks again
chris
cwess
Apr 12 2005, 02:00 AM
Even though it worked, you mentioned "then you should not be trying to save this "due date" value in your table as it would violate the Normal Form ... "
What exactly do you mean and will it hurt to store the actual date in the "due date" table...?
chris
JayNoelOlimpo
Apr 12 2005, 02:10 AM

You're WELCOME.
Calculated values should never be stored in a table ...
as they are calculated on the fly ...
You should only store the option selected (Numeric I guess) and the date of transaction ...
then only in the form and reports should those values be calculated ...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.