Alpha Video Training
Results 1 to 3 of 3

Thread: change or enter mode?

  1. #1
    Member
    Real Name
    David Volgas
    Join Date
    Feb 2001
    Location
    Columbia, MO
    Posts
    443

    Default change or enter mode?

    I have an OnPush event on a form which should trigger calculations based on values entered on the form. I then want to populate fields on the form with the result of these calculations. Unfortunately, the calculations are somewhat complicated by the fact that each summary field is calculated a different way and there are rules which I have coded which account for missing values, etc.

    My question is this: when I try to update the form fields directly using the statement

    t.dailycat = var_dailycat

    where dailycat is the name of the form's control, t is the form pointer, opened with table.current(), and var_dailycat is a layout variable which contains the result of my calculations.

    However, when I run the form, I get an error message that the table is not open in change or enter mode. So, I added a table.enter_begin statement before the above statement and then table.enter_end, but still get errors.

    What mode does the table.current() open the table in? I can read form fields using the t.daily1 method to read the field daily1 with no problem. Why can't I also write using the same method?

    Thank you,

    Dave
    David A. Volgas, MD

  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: change or enter mode?

    Quote Originally Posted by davidv43 View Post
    What mode does the table.current() open the table in?
    It doesn't open anything. It establishes a pointer to the currently open table.

    table.enter_begin statement before the above statement and then table.enter_end,
    The syntax would be

    t.enter_begin()
    and then
    t.enter_end(.t.)

    What you probably want is something like

    Code:
    t = table.current()
    if t.mode_get()= 1 then
    t.dailycat = var_dailycat
    elseif tbl.mode_get()= 2 then
    t.dailycat = var_dailycat
    else
    t.change_begin()
    t.dailycat = var_dailycat
    t.change_end(.t.)
    end if
    Last edited by Stan Mathews; 07-25-2008 at 03:19 PM.

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,312

    Default Re: change or enter mode?

    David, the user may have begun a change or begun a new record or simply be viewing the current record.

    If you get a pointer to the primary table supporting the form with

    t = current()

    then you can use t.mode_get() to get the mode of the table when the script is running.

    Unless the table is in change or enter mode you can't assign field values to the record buffer, which is what your

    t.dailycat = var_dailycat

    is doing.

    You can read the field value regardless of the mode, but you can't assign a value to the field in the record buffer without placing the table in change or enter mode.

    Naturally, if your table is already in change or enter mode because of what the user has done your script doesn't need to begin a change or enter, any attempt to do so after the change or enter has already started will throw a different error.

    So, long story short,

    change your script to get the mode

    if the mode is 1 (change) then do something

    if it's 2 (enter) then do something else

    if it's 0 (view) then do something else altogether.

    And.... don't forget to refresh any objects in your form displaying field values that are changed.

    -- tom

Similar Threads

  1. change table in enter mode
    By aau Ching in forum Alpha Five Version 5
    Replies: 4
    Last Post: 12-05-2003, 02:48 PM
  2. Ok in Change mode but not Enter
    By Robert Picard in forum Alpha Five Version 4
    Replies: 11
    Last Post: 05-19-2001, 09:13 PM
  3. Change / Enter Mode BUG!!??
    By forskare in forum Alpha Five Version 4
    Replies: 0
    Last Post: 09-15-2000, 06:38 AM
  4. Enter or Change Mode
    By forskare in forum Alpha Five Version 4
    Replies: 5
    Last Post: 09-13-2000, 06:43 PM
  5. table not in change or enter mode
    By Lloyd Frank in forum Alpha Five Version 4
    Replies: 15
    Last Post: 06-30-2000, 05:33 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
  •