View Full Version : Date from Variable


01-10-2004, 02:28 PM
I would like to use a variable 'vcdate' in the field rules as a calculated value. Can someone enlighten me as to how to do it?

01-10-2004, 07:07 PM
Can you explain what you are actually trying to accomplish rather than how you are trying to accomplish it?

From what I read, I have no idea what you are asking. A variable is a variable. It can be calculated based on something but I can't imagine putting both the calculation and the variable in a field rule - one or the other but not both.

01-10-2004, 07:55 PM
Hello Cal,

Perhaps I've been trying to do this the wrong way.
I have several tables which require a date which I need to supply. I don't want the system date.
From my Main Menu,I run a script that Opens one of these tables and also prompts for a date.
I need to know the technique to have this date automatically fill in a field so I can enter multiple records without re-entering the date for each new record until I exit it. I hope this makes sense to you.

Tom Cone Jr
01-11-2004, 01:51 AM

An important design decision for you will be whether to populate the date field in new or changed records via field rules or whether to do it in your data entry form. My personal practice is to avoid embedding user supplied variable values in field rules. If the desired value can be computed using an Xbasic expression you don't need a variable. Otherwise, if you're counting on the user to supply a specific value then I wouldn't try to capture that value in a variable and use it in field rules. Instead I'd do it in the data entry form.

If you declare the variable shared you can use the user supplied value over and over as new records are entered through the form in a single session. Short scripts can be used to automatically assign the user supplied variable value to the date field as new records are entered.

-- tom

01-11-2004, 07:12 AM
I think this may solve your problem:

Use a default for the date and check the "Set default value at start..." box. Here's the default definition:


Where "fld_namef" is the name of the current field (the date field) and needs to be enclosed in quotes just as shown above.

Using "" as the second argument tells PREVIOUS to use the record number order thus finding the last record that was entered.

Now you don't even have to prompt for the date AND, if the date changes because all info for date #1 is done and the user is ready to switch to data for date #2, all the user does is change the date on the first record for the "date #2" data. The user changes it once and that becomes the default until it's changed again.

Look up PREVIOUS in the AlphaFiveHelp.chm for more details.

01-11-2004, 07:21 AM
By the way, I agree with Tom's comments about using variables in field rules.

It can be done but it requires a lot of care to make sure you've covered all the possibilities - like what happens if the variable doesn't exist for some reason? Of course, there are always exceptions and there are times you need to do something that isn't "recommended" practice but it sounds like you can avoid potential problems on this one.