This topic is locked

two date field questions

10/9/2006 8:26:39 AM
ASPRunnerPro General questions
B
bgilbert author

Hi
New to ASPRunner with two simple Date field questions!!!

  1. need to have a date field that on "new" screen uses the Now() function, but on edit does not use the Now() function. in other words, if the field is blnak use Now() otherwise leave as is. Does anyone have ideas how i can do this??
  2. also have another date field that needs to be conditonal on other field on screen ie, if FieldA =p then date = Now() + 8, if FieldA = e then date = Now(). Any ideas how to do this??
    Thanks for any hlp.

J
Jane 10/9/2006

Hello,
you can do it using events.

Proceed to the events tab, select BeforeEdit event and add your code in it.

Here is a sample code:

Function BeforeEdit(dict, where)

if dict("DateField")="" then

dict("DateField") = Now()

end if
if dict("FieldA")="p" then

dict("DateField") = Now()+8

end if
if dict("FieldA")="e" then

dict("DateField") = Now()

end if
BeforeEdit = True

End Function



where DateField is your actual field name.
Also set default value of DateField field to Now() on the ADD page.

B
bgilbert author 10/11/2006

Hi Jane
THanks for the prompt reply and the code. it works just great.
The only follow issue i have is how to hide the DateField in the "add" screen.
If i do this in the "Choose Fields" step, then the code fails to work - as do any other function calls. If i include the DateField in the Add screen, then users can tpye any dates in.
Ideally i wanted to have the code work as the user entered p or e in the type field - filing in the Datefield accordingly, so when the user got to the DateField then the calculated date was already entered for them to accept.
but your solution works fine, if i can hide the DateField in the Add screen, meaning if the date is not correct then the user will need to edit the record.
Hope that makes sense??
Barry.

Hello,

you can do it using events.

Proceed to the events tab, select BeforeEdit event and add your code in it.

Here is a sample code:
where DateField is your actual field name.
Also set default value of DateField field to Now() on the ADD page.

J
Jane 10/11/2006

Barry,
if you use ASPRunner 4.0 you can set up your DateField to Hidden in the Edit as dropdown box on the Formatting tab.
In the ASPRunner 4.1 you can uncheck your DateField from ADD page and use your event code without modifications.