Default today's value in a field and calculated field

20 views
Skip to first unread message

M.Emmanuel

unread,
Sep 25, 2025, 5:15:52 AM (10 days ago) Sep 25
to TheDBCommunity
I am beginning with custom forms.
I can not use form editor because seems to be designed for 80x25 only.

In below's form, how would you make the invoice date field F_INVDATE:
- To have today's value as default
- To have DD-MON-YYYY format

And how would you make the invoice due date field F_DUEDATE:
- To have F_INVDATE + 30 days, and 
- if the date in F_INVDATE changes, this changes too.

Thanks,

CLEAR

SHOWDIALOG "New Invoice"
@0,0 HEIGHT 59 WIDTH 131

@ 2,2 ?? "        INV NUMBER: "
ACCEPT @ 2,25
WIDTH 13 "A10"
TO F_INVNUMBER

@ 3,2 ?? "          INV DATE: "
ACCEPT @ 3,25
WIDTH 13 "D"
TO F_INVDATE

@ 4,2 ?? "          DUE DATE: "
ACCEPT @ 4,25
WIDTH 13 "D"
TO F_DUEDATE

PUSHBUTTON @ 10,2
WIDTH 10
"~S~ave"
DEFAULT
OK
VALUE "OK"
TAG "Yes"
TO Button

ENDDIALOG

Steven Green

unread,
Sep 25, 2025, 9:05:58 AM (9 days ago) Sep 25
to TheDBCommunity
F_INVDATE = format("w8,d5",today())
F_DUEDATE  = format("w8,d5",today()+30)

M.Emmanuel

unread,
Sep 25, 2025, 11:13:20 AM (9 days ago) Sep 25
to TheDBCommunity
Thanks

I still can not manage to format the date, if I assign F_DUEDATE in advance as below a weird date is displayed (12/31/0).
If I uncomment the PICTURE FORMAT then everything is displayed well, but you can not really change the date later in the form.
If I ignore formatting then everything works fine

```
CLEAR

;F_INVDATE = TODAY()
F_DUEDATE = FORMAT("W11,D7", TODAY()+30)


SHOWDIALOG "New Invoice"
@0,0 HEIGHT 59 WIDTH 131

@ 2,2 ?? "        INV NUMBER: "
ACCEPT @ 2,25
WIDTH 14 "A10"
PICTURE "####{-}###"

TO F_INVNUMBER

@ 3,2 ?? "          INV DATE: "
ACCEPT @ 3,25
WIDTH 14 "D"

TO F_INVDATE

@ 4,2 ?? "          DUE DATE: "
ACCEPT @ 4,25
WIDTH 14 "D"
; PICTURE FORMAT("W11,D7", TODAY())

TO F_DUEDATE

PUSHBUTTON @ 10,2
WIDTH 10
"~S~ave"
DEFAULT
OK
VALUE "OK"
TAG "Yes"
TO Button

ENDDIALOG
```

Steven Green

unread,
Sep 25, 2025, 11:37:07 AM (9 days ago) Sep 25
to TheDBCommunity
you assign the vars before the dialog, not in the dialog.. my thoughts might be off a bit, might not have time to look into it til later.. if you're trying to learn basic stuff in pdoxdos from scratch, there is limited assistance here, or anywhere.. time much better spent learning something with tons of online support

Mario Emmanuel

unread,
Sep 25, 2025, 1:45:46 PM (9 days ago) Sep 25
to thedbco...@googlegroups.com
I have tried:

1. Assigning it outside the SHOWDIALOG. This works and the dialog appears with that default value.
2. Assigning it inside the SHOWDIALOG generates an error, seems that SHOWDIALOG only allows to put components inside.

What is not working (maybe is not even possible) to have that field to format the date in a certain way (D7 in particular).
or maybe I have not managed to fully understand how the picture clause works.

@ 4,2 ?? "          DUE DATE: "
ACCEPT @ 4,25
WIDTH 14 "D"
PICTURE "D7"
TO F_DUEDATE

--
You received this message because you are subscribed to a topic in the Google Groups "TheDBCommunity" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/thedbcommunity/Y0evCm_Ap2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to thedbcommunit...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/thedbcommunity/f68a10bd-f3a2-43d2-bac1-3ea7234b706dn%40googlegroups.com.

Steven Green

unread,
Sep 25, 2025, 1:59:13 PM (9 days ago) Sep 25
to TheDBCommunity
picture would be ##/##/#### or whatever date format you want.. D7 is a formatting option

Mario Emmanuel

unread,
Sep 25, 2025, 5:41:04 PM (9 days ago) Sep 25
to thedbco...@googlegroups.com
I see,

With this you force the user to enter dates in format [D]D-MON-YYYY.

However, if you assign a date to F_DUEDATE, it seems it is not possible to choose the format used to display the value in the ACCEPT field (it is possible in regular form fields where you can choose the format in the table and that, according to the programming guide will be translated to the form)

@ 4,2 ?? "          DUE DATE: "
ACCEPT @ 4,25
WIDTH 14 "D"
PICTURE "#,##-&&&-####"
TO F_DUEDATE


Message has been deleted

Gernot Langle

unread,
Sep 26, 2025, 3:54:36 PM (8 days ago) Sep 26
to TheDBCommunity
Try adding DEFAULT parameter, like this:
@ 4,2 ?? "          DUE DATE: "
ACCEPT @ 4,25
WIDTH 14 "D"
PICTURE "#,##-&&&-####"
DEFAULT today() TO F_DUEDATE

Mario Emmanuel

unread,
Sep 26, 2025, 6:40:50 PM (8 days ago) Sep 26
to thedbco...@googlegroups.com
Thanks,

ACCEPT does not allow DEFAULT when used inside SHOWDIALOG, it does not work (interpreter error: expected TO).

The PAL REFERENCE for PARADOX 4 specifies that "ACCEPT uses the same arguments as its outside dialog counterpart". But when enumerating all the components with their parameters that can be defined inside a SHOWDIALOG the DEFAULT is removed for ACCEPT.

I guess you can not really control the formatting of input date fields other than using an A field and using PICTURE and then using FORMAT to display the date.

Reply all
Reply to author
Forward
0 new messages