Fill in a date field automatically
  • Rob
    Fill in a date field automatically

    by Rob » Wed Sep 20, 2006 12:10 pm

    A simple question I hope. I have created a card file with a date field on it called Created. When users press save, I'd like the date field to be filled in automatically if the date field is blank.
  • COBS Tech Support
    Posts:683
    Joined:Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Wed Sep 20, 2006 12:13 pm

    From the Screen Builder main menu select File|Screen Script.

    On event 3 (save) you would execute the following script or similar:

    If Mode = 3 .And. IsEmpty(SCRRead("Created"))
    SCRWrite("Created", Today())
    Endif
  • Rob

    Time

    by Rob » Wed Sep 20, 2006 12:20 pm

    Sorry, how would I do this for recording the current time in my card file as well?
  • COBS Tech Support
    Posts:683
    Joined:Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Wed Sep 20, 2006 12:22 pm

    Make your time field character type, with a field length of 5 if you just want to record hours and minutes.

    Assuming the field name is CREATETIME, your revised script would be:

    If Mode = 3
    If IsEmpty(SCRRead("Created"))
    SCRWrite("Created", Today())
    Endif

    If IsEmpty(SCRRead("Createtime"))
    SCRWrite("Createtime", Left(Time(), 5))
    Endif
    Endif

Who is online

Users browsing this forum: No registered users and 24 guests