This topic is locked

Setting a Field Default Value.

9/13/2008 12:28:55 PM
ASPRunnerPro General questions
W
Wanda author

I need to set a field (in this case [Update Date]) to the current date NOW().
The requirement is is that I'd like to do this beforea record is added/edited (physically displayed on screen) so that I can set the field to Read Only on both pages. I have similar fields (that are bit types and I need to do the same sort of thing)
The Query Editor does not allow this much flexability - unless I'm out to lunch.
I've tried this in Before record added (only valid for Add and InLine Add) and Before record updated (only valid for Edit and Inline Edit). But it doesn't work in either case. I've even copied a code snippet from the web site "How To" but it doesn't work either (this snippet converts to Proper Case).
I gotta be doing something goofy, but what I dunno...
In both cases, I get no error, just no data stored in the field.
Any help would be appreciated.
Thanks

customcode 9/13/2008

I need to set a field (in this case [Update Date]) to the current date NOW().

The requirement is is that I'd like to do this beforea record is added/edited (physically displayed on screen) so that I can set the field to Read Only on both pages. I have similar fields (that are bit types and I need to do the same sort of thing)
The Query Editor does not allow this much flexability - unless I'm out to lunch.
I've tried this in Before record added (only valid for Add and InLine Add) and Before record updated (only valid for Edit and Inline Edit). But it doesn't work in either case. I've even copied a code snippet from the web site "How To" but it doesn't work either (this snippet converts to Proper Case).
I gotta be doing something goofy, but what I dunno...
In both cases, I get no error, just no data stored in the field.
Any help would be appreciated.
Thanks


Wanda,

go to visual editor as it will allow you to set the default value to now() with the properties set to read only.

W
Wanda author 9/13/2008

Sorry, my bad. I know that the Editor allows me to set the Default Values. What I need to do is to set default values prior to loading the page. For example, in a master table, I have an ItemNo field. In the related table (i.e child) I need to add one to this value prior to the child table being displayed.
In the Editor, I can set the default value and set read only, the problem is is that it is read only in the Edit and Add page. So when I add a new record to the child, I can't seem to get the value from the master table nor can I edit it. I want to be able to display a new value in ADD, yet Edit it on the Edit page.
So I need to be able to set the value on the Add Page, and Edit it on the Edit page.
I hope I'm making sense here, I hate to waste people's time.
Hmmm, am I missing something real simple here?
Thnaks...

Sergey Kornilov admin 9/14/2008

As a first step I recommend to check manual topic Page life cycle overview
BeforeProcessEdit - Ocurrs after page is processed and ready to be displayed in the browser.

BeforeEdit - Occurs before new data is written to the database.
If you like to execute some code before page is displayed, use BeforeProcessEdit event.
For example you can use this event to pull data from master table (ItemNo field value). Session variable SESSION($strTableName."_masterkey1") holds master key value from master table. You can find more info about ASPRunnerPro session variables at http://www.xlinesoft.com/asprunnerpro/docs...n_variables.htm
Once you retrieved ItemNo value store it in session variable like Session("ItemNo"). Then you can use Session("ItemNo") as a default value of any field on the Add page.
If you need more detailed advice post your app to DemoAccount and contact support team directly at support@xlinesoft.com.

W
Wanda author 9/25/2008

Thank you very much. This is what I was looking for.
Having a little problem with coding, but that's just me and syntax.
This is a great forum, lots of help, pointers and knowledge.
Again, thanks.
W.