CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 How to programmatically create values for a key field

Print topic Send  topic

Author Message
gordowa

Posts: 4
Posted: 04/23/2004, 1:52 PM

I have a record form that has a text box called "ar_no". I call this from from a menu option called "create a new ar". I want to programmatically generate the "ar_no" value based on the current date and a serial number like "20040101-005". I used the "before show" event and successfully generated my "ar_no" value which displays correctly in the text box, but when the "insert" button is clicked to add the record, the SQL insert command has "null" for the "ar_no" field. What am I doing wrong or leaving out?
View profile  Send private message
peterr


Posts: 5971
Posted: 04/24/2004, 8:39 PM

You may need repeat the same code in the "Before Insert" event of the Record form. The Before Show event is executed only when the page is displayed, but not when the data is submitted by the users.
Please also note that this should work TextBoxes but not Labels.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
gordowa

Posts: 4
Posted: 04/26/2004, 2:22 PM

Okay. I tried the suggestion, but it didn't work. More than likely my fault since I am new to the more advanced capabilities of CodeCharge. I have a page called "AddEm" with a form variable called "ARNo" on a form called "NewAR". If I was to create a user defined function called "CreateMyOwnValue" that returned the ARNo I generate, couldn't I call that function from the "default" property of the "ARNo" form field? If so, where would I put the "CreateMyOwnValue" function so it wouldn't get overwritten during the code generation cycle? I don't have a problem if I prepopulate values of a form field using the "default" property. Thanks.
View profile  Send private message
peterr


Posts: 5971
Posted: 04/26/2004, 3:13 PM

Hi,

A function (standard or custom) should work when placed in the "Default" property of the field, as long as the field is updateable (not a Label), otherwise the value will be shown but not written to the database.

There are 3 usual areas where you can place custom code or functions. If you want the function to be available globally (within all pages) then you can place it at the end of Common.asp. Otherwise you can place it at the beginning (or end) of the generated page code (page.asp) but within the white background area. Avoid changing the generated code blocks marked by the grey background. If you utilize any Events on your page, you can place the function in the events file (page_events.asp), either at its beginning, end, or between the event functions.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
gordowa

Posts: 4
Posted: 04/27/2004, 9:11 AM

Okay. Chalk this one up to inexperience with the CodeCharge product. Out of pure ignorance, I checked the "disabled" box in the format tab of the ARNo form field thinking that was the proper way to keep the user from editing the field once I had created the value I wanted. Ooops. While disable keeps the user from modifying the field, it also prevents the "Insert" function from using the value I created. Unchecking "disabled" fixes the "insert" record problem. Now that brings up a different question. How do I protect fields from being modified by the user? I noticed that the "readonly" format property is only available for text fields. What about list boxes, check boxes, and radio boxes, etc. Thanks.
View profile  Send private message
Tony Do
Posted: 05/02/2004, 6:36 PM

The hidden textbox come to the rescue.
I would disable my listbox so that It is only display to the screen and no
update.
I will then have a hidden field that bind to the same field as the listbox
that has been disabled.

When ever you want to programatically change the value change the value to
both field.

"gordowa" <gordowa@forum.codecharge> wrote in message
news:6408e8627abf8a@news.codecharge.com...
> Okay. Chalk this one up to inexperience with the CodeCharge product. Out
of
> pure ignorance, I checked the "disabled" box in the format tab of the ARNo
form
> field thinking that was the proper way to keep the user from editing the
field
> once I had created the value I wanted. Ooops. While disable keeps the
user
> from modifying the field, it also prevents the "Insert" function from
using the
> value I created. Unchecking "disabled" fixes the "insert" record problem.
Now
> that brings up a different question. How do I protect fields from being
> modified by the user? I noticed that the "readonly" format property is
only
> available for text fields. What about list boxes, check boxes, and radio
> boxes, etc. Thanks.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.