Alpha Video Training
Results 1 to 10 of 10

Thread: don't allow to edit the data in the past

  1. #1
    Member
    Real Name
    Peterth
    Join Date
    Oct 2009
    Posts
    278

    Default don't allow to edit the data in the past

    Hi all,

    Please recommend me what command is the best to protect the data from user to edit it?
    I have table and user will key in it everday. Usually user can press Page up and PageDown to view and edit the data from form.
    How and what command I have to use to protect user to edit the previous data they key in yesterday or the day before yesterday. I don't want them edit the data in the past. They can create and edit only with in current day

    I know the modal and modeless but I don't know how to force form to modal if it's not today. (if it's not today and form will be setup to modal)
    I don't know other command that meet this requirement.

    Thanks
    Peter

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

    Default Re: don't allow to edit the data in the past

    In the OnActivate event:

    Code:
    t =table.current()
    
    If t.date < date()
    
    This.allow_change(.F.) 
    
    else 
    
    This.allow_change(.T.) 
    end if
    You might also need it in the OnFetch event if you allow fetching.

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

    Default Re: don't allow to edit the data in the past

    In the OnActivate event:
    Code:
    t =table.current()
    If t.date < date()
    This.allow_change(.F.)
    else
    This.allow_change(.T.)
    end if


    You might also need it in the OnFetch event if you allow fetching.

  4. #4
    Member
    Real Name
    Peterth
    Join Date
    Oct 2009
    Posts
    278

    Default Re: don't allow to edit the data in the past

    Hi Peter,

    Thank you for your quick response and your sample code

    Thank you very much
    Peter-th

  5. #5
    Member
    Real Name
    Peterth
    Join Date
    Oct 2009
    Posts
    278

    Default Re: don't allow to edit the data in the past

    Hi Peter,

    I have to define t variable and what kind of it ?

    Thanks
    Peter-th

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

    Default Re: don't allow to edit the data in the past

    Any variable that references a table like

    t =table.current()

    is a pointer (dot) variable.

    Dim t as P

    is proper but not necessary. The assignment statement implicitly defines it.

    Using the pointer variable you can reference the fields in the table like

    t.fieldname using an actual fieldname
    There can be only one.

  7. #7
    Member
    Real Name
    Peterth
    Join Date
    Oct 2009
    Posts
    278

    Default Re: don't allow to edit the data in the past

    Hi Stan,

    Thank you for your more details for the pointer variable.
    I have never used it before and I have to learn it more how to use it
    I think it's time to use it many places in my application

    Thank you for advise
    Peter-th

  8. #8
    Member
    Real Name
    Peterth
    Join Date
    Oct 2009
    Posts
    278

    Default Re: don't allow to edit the data in the past

    Hi Peter,

    Thank you for your sample I can do it now.
    Is it possible if I use more condition to allow user edit the data
    I use the save botton and add more command after save record to set the status of some field to t/f (to protect user change clock in PC)

    I have more a field for status in the table

    id date expense status
    001 3/3/2010 500 T
    002 4/3/2010 620 F

    when user key in the data within form and click Save botton then I have a command (next command to save record) to set the Status field to T

    so when user click save botton. He will cannot edit the data evenif he try to change clock of PC.

    The problem is I don't know what command I can use and add more in the Save botton to force the Status to T

    Thank you for your commandation.

    Peter-th

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

    Default Re: don't allow to edit the data in the past

    Quote Originally Posted by peterth View Post
    The problem is I don't know what command I can use and add more in the Save botton to force the Status to T
    Maybe in the CanSave event you put something like:

    FieldObjectName.value = .T.

    The CanSave fires before the Save event. It might work in the save event too, but I forget. Yow will need to put the field on your form, but you can hide it. Usually, Alpha automatically gives the field object the same name as the field itself.

  10. #10
    Member
    Real Name
    Peterth
    Join Date
    Oct 2009
    Posts
    278

    Default Re: don't allow to edit the data in the past

    Thank you for your advise. I will try it again.

    Thank you ver much.
    Peter-th

Similar Threads

  1. Saving new data in a record list edit combo box
    By MDPriority in forum Alpha Five Version 10 - Desktop Applications
    Replies: 1
    Last Post: 11-22-2009, 02:07 AM
  2. Browse-Dialog data entry & edit
    By Peter.Greulich in forum Code Archive
    Replies: 36
    Last Post: 04-19-2009, 09:33 PM
  3. How to freeze past invoices
    By gaby_h in forum Alpha Five Version 9 - Desktop Applications
    Replies: 12
    Last Post: 11-10-2008, 11:11 AM
  4. Edit Data in Excel Spreadsheet
    By AndyLieberman in forum Alpha Five Version 8
    Replies: 6
    Last Post: 05-21-2007, 06:57 PM
  5. Auto advancing past required data field
    By Connie Brouillette in forum Alpha Five Version 5
    Replies: 3
    Last Post: 09-01-2004, 09:22 PM

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
  •