Alpha Video Training
Results 1 to 8 of 8

Thread: Automatically inserting date

  1. #1
    Member
    Real Name
    Mike Vasilinda
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    8

    Default Automatically inserting date

    I have an A5V5 database of videotapes in which I would have available the date of the LAST time the form was opened, so I have a reference of when the tape was last used. Ideally, the date should insert as the form is being closed so that the next time it is opened, it will have the previous date, and so on and so on.

    Perplexed beyond my abilities. thanks for the help. mv

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Automatically inserting date

    Quote Originally Posted by mikev View Post
    I have an A5V5 database of videotapes in which I would have available the date of the LAST time the form was opened, so I have a reference of when the tape was last used. Ideally, the date should insert as the form is being closed so that the next time it is opened, it will have the previous date, and so on and so on.

    Perplexed beyond my abilities. thanks for the help. mv
    Database Design Forum for questions about general database design. Specific questions related to Alpha Five should be placed in the appropriate Alpha Five forum
    To answer your question, anyway, what you are probably wanting is that when a record is edited/changed the date is recorded. This is generally done through the onchange for a form field. In your case the syntax would be something like

    datefieldobjectname.value = date()

    where datefieldobjectname is the object name of the date field you want changed as it appears on your form. This is usually the same as the table field it represents but can be different. You will find the actual object name by examining the field's properties.

    I say, "what you probably want" because I can't understand why you would want to change the date if a record was merely viewed, not changed. You probably don't mean "date of the LAST time the form was opened" because at that point you don't even know what record is being displayed.

  3. #3
    Member
    Real Name
    Mike Vasilinda
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    8

    Default Re: Automatically inserting date

    Thanks Stan. The reason I want to change the date, even if the form has not been changed is because, while the foprm wasn't changed, teh videotape whish is repreesnted by the record was used for a purpose, and I want to know the last time the tape was used. I'll try to work through your idea.

  4. #4
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,644

    Default Re: Automatically inserting date

    You need to put some xbasic in one of the form's events, perhaps the CanExit event:

    parentform.commit()
    tbl=table.current()
    tbl.change_begin()
    tbl.date = Date()
    tbl.change_end(.T.)
    END

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Automatically inserting date

    Quote Originally Posted by mikev View Post
    Thanks Stan. The reason I want to change the date, even if the form has not been changed is because, while the foprm wasn't changed, teh videotape whish is repreesnted by the record was used for a purpose, and I want to know the last time the tape was used. I'll try to work through your idea.
    Still doesn't make sense to me. I think you are using the terms form and record interchangeably when they are not.

    What must be happening is that you are in some part of your application, you search for and display the desired record in the form of which you are speaking. At that point, no matter what action is taken, you want to update a date field in the visible record to the current date. I would suggest you use the code supplied for the onexit event for this form rather than the previously suggested onchange event for a field on the form.

    This should do what you want if the form is not used for any other purpose.

  6. #6
    Member
    Real Name
    Mike Vasilinda
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    8

    Default Re: Automatically inserting date

    Thanks. You are right. I am using the terms form and record interchangeably, when they are not. I'm out till the new year but will try your latest idea when I get back. Happy holidays! mv.

  7. #7
    Member
    Real Name
    Mike Vasilinda
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    8

    Default Re: Automatically inserting date

    Quote Originally Posted by Peter.Greulich View Post
    You need to put some xbasic in one of the form's events, perhaps the CanExit event:

    parentform.commit()
    tbl=table.current()
    tbl.change_begin()
    tbl.date = Date()
    tbl.change_end(.T.)
    END
    This works for me thanks. One small thing. I had to eliminate the line of code
    tbl.date = Date() because it also changed the date on the record as well as the field date last accessed. thanks for your help. mv

  8. #8
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Automatically inserting date

    along the same lines but a bit different. One app I have has the user(logged in) and on change/add it takes the username, datetime and the account number of the record and stores it in another table I call log.dbf. More information(such as amounts and other field changes could also be stored) could be added to the log.

    It is easy to set up this one.

    Dave

Similar Threads

  1. Inserting system date through event
    By René Stout in forum Web Application Server v7
    Replies: 10
    Last Post: 07-05-2007, 05:13 PM
  2. Automatically adding date, time and User_Name() to a memo field
    By GaHaKa in forum Alpha Five Version 7
    Replies: 4
    Last Post: 01-18-2006, 12:56 AM
  3. Inserting a record
    By Mario Lenza in forum Alpha Five Version 6
    Replies: 4
    Last Post: 09-16-2005, 02:44 AM
  4. Inserting fields
    By Bob Lambert in forum Alpha Five Version 5
    Replies: 6
    Last Post: 08-06-2003, 07:39 AM
  5. Inserting Fields
    By edward.mattison@scbhn.org in forum Alpha Five Version 4
    Replies: 8
    Last Post: 06-19-2002, 11:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •