Alpha Video Training
Results 1 to 5 of 5

Thread: Post() method in caninsertrecord in grid

  1. #1
    Member EricN's Avatar
    Real Name
    Eric
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    553

    Default Post() method in caninsertrecord in grid

    So far I have this in my grid's caninsertrecord event connected to "posts" table

    If (DataSubmitted.Site_name = "") then
    Result.Cancel = .t.
    Result.ErrorHTML = "Please enter your site name and information."
    exit function
    end if

    dim tbl as p
    dim Ads_allowed as n

    tbl = table.open("[PathAlias.ADB_Name]\users.dbf")
    ' subtract 1 from Ads_allowed
    post.t_db = "[PathAlias.ADB_Name]\users\Ads_allowed"
    post.m_key = "userid"
    post.t_key = "userid"
    post.m_filter = " "
    post.m_count = 1
    post.m_field1 = "ads_allowed"
    post.m_exp1 = "ads_allowed" - 1
    post.t_count = 0
    tbl.post()
    ui_msg_box("Your job has been posted.")
    Result.Cancel = .f.
    Result.ErrorHTML = ""
    end with
    end function

    I want to subtract 1 from the Ads_allowed field in the users table each time the user presses the submit button and successfully enters a new record.

    I'm getting this error.
    500 Internal Server Error
    "Script Error
    Error:command: post.m_exp1 = "ads_allowed" - 1
    Argument is incorrect data type"
    Last edited by EricN; 01-21-2008 at 03:56 PM.
    Eric

    Alpha Five Websites
    longlivepuppies.com
    socialservicenetwork.com
    -------------------------------------------------
    socialservicenetwork.org

  2. #2
    Member EricN's Avatar
    Real Name
    Eric
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    553

    Default Re: Post() method in caninsertrecord in grid

    Wish I could edit my original post above...

    I have this in my grid's caninsertrecord event connected to "posts" table

    dim tbl as p
    dim Ads_allowed as n
    dim Ad_count as n
    dim Post_limits as n

    ' subtract 1 from users table's (Post_limits field) using posts table's (ad_count field) which is set to 1
    tbl = table.open("[PathAlias.ADB_Name]\posts.dbf")
    post.t_db = "[PathAlias.ADB_Name]\users"
    post.m_key = "userid"
    post.t_key = "userid"
    post.m_count = 1
    post.m_field1 = "Ad_count"
    post.m.exp1 = "Ad_count - @Post_limits"
    'post.m_exp1 = "Post_limits - @Ad_count"
    post.t_count = 0
    tbl.post()
    ui_msg_box("Your job has been posted.")


    I want to subtract 1 from the Ads_allowed field in the users table each time the user presses the submit button and successfully enters a new record.

    I'm now getting this error
    500 Internal Server Error
    "Script Error
    Error:command: tbl.post()
    Required variable post.m_exp1 was not defined."

    If I do this
    'post.m.exp1 = "Ad_count - @Post_limits"
    post.m_exp1 = "Post_limits - @Ad_count"

    I get this error
    500 Internal Server Error
    "Script Error
    Error:command: tbl.post()
    Variable post.m_exp1 references a non-existent field POST_LIMITS - @AD_COUNT."
    Eric

    Alpha Five Websites
    longlivepuppies.com
    socialservicenetwork.com
    -------------------------------------------------
    socialservicenetwork.org

  3. #3
    Member EricN's Avatar
    Real Name
    Eric
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    553

    Default Re: Post() method in caninsertrecord in grid

    I'm getting closer. This is what I now have in caninsertrecord for my grid


    dim dbl as p
    tbl = table.open("[PathAlias.ADB_Name]\users.dbf")
    post.t_db = "[PathAlias.ADB_Name]\posts.DBF"
    post.m_key = "USERID"
    post.t_key = "USERID"
    post.m_filter = ""
    post.t_filter = ""
    post.m_count = 1
    post.m_field1 = "Post_Limits"
    post.m_exp1 = "Post_Limits-@Posts->Ad_Count"
    post.t_count = 0
    tbl.post()

    I don't get any errors on the screen but:
    1) It updates all the records in my users table regardless of userid during a transaction.
    2) It subtracts more 1 for each post. It is adding all the previous posts with same userid and subtracting the total from the users field.

    Filter?
    Eric

    Alpha Five Websites
    longlivepuppies.com
    socialservicenetwork.com
    -------------------------------------------------
    socialservicenetwork.org

  4. #4
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Re: Post() method in caninsertrecord in grid

    Eric,

    Either a filter or how you are determining the Ad_Count. You stated that Ad_Count is a field when I would think that it should be just a Calculated field. If it really is a Calc field then this is the first place I would look to see if your calc script is correct or needs to be modified.

    Note: Web side is the Dark side to me yet! But this question is sort of cross platform so put my 2 cents in!
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  5. #5
    Member EricN's Avatar
    Real Name
    Eric
    Join Date
    May 2007
    Location
    Minnesota
    Posts
    553

    Default Re: Post() method in caninsertrecord in grid

    Thank you for responding Mike.
    I think I will take Pat and Doug's suggestion to me in this thread http://msgboard.alphasoftware.com/al...ad.php?t=71282 using the dbcount()

    After reading up on it, it does seem to make much more sense to me.
    Eric

    Alpha Five Websites
    longlivepuppies.com
    socialservicenetwork.com
    -------------------------------------------------
    socialservicenetwork.org

Similar Threads

  1. Help-CanInsertRecord/page refresh strategy
    By rjonas in forum Web Application Server v7
    Replies: 2
    Last Post: 11-01-2006, 06:55 PM
  2. variables in the POST method
    By Steve Wood in forum Web Application Server v7
    Replies: 4
    Last Post: 07-10-2006, 06:31 AM
  3. CanInsertRecord & CanUpdateRecord events result in error on Delete
    By Tarek in forum Web Application Server v7
    Replies: 9
    Last Post: 04-30-2006, 03:15 PM
  4. Replies: 1
    Last Post: 12-11-2005, 05:42 PM
  5. Post vs. table method
    By Ken L Herrold in forum Alpha Five Version 4
    Replies: 3
    Last Post: 03-05-2002, 06:30 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
  •