Alpha Video Training
Results 1 to 2 of 2

Thread: Need to fill 2 tables with one click

  1. #1
    Guest
    Real Name
    Jack Forman
    Join Date
    May 2009
    Posts
    58

    Default Need to fill 2 tables with one click

    This code worked until I add the section in red, that would create as many records in the t_place table as many records are created in the t_contract.

    I am not saving any records to table t_spaces. My coding is not working.

    I am attaching a sample of the application
    Perhaps some one can correct my erroneous code

    Here is the code:


    DIM SHARED vEmployee AS c
    vEmployee = parentform:Employee.value
    DIM SHARED vWorksUnder AS c
    vWorksUnder = parentform:Worksunder.value
    DIM SHARED cContractAmt AS n
    vContractAmt = parentform:Contractamt.value
    Dim nMaxIdSeq as N
    ' new
    Dim nMaxIdtot as N
    nMaxIdSeq = tableMax("t_contracts","Employee_work = \""+ vWorksUnder+"\"","IdSeq")
    'nMaxIdtot = dbcount("t_contracts","Works_under",Works_under)
    'nMaxIdtot = tablecount("t_contracts","Works_under = "+quote(Works_under))
    'nMaxIdtot = TABLECOUNT("t_contracts","Works_under = '" + Works_under + "' ")
    'tbl = table.current()
    'J_Title = tablecount("Jobs.dbf","Title = "+quote(tbl.Title))
    '''ui_msg_box("Count",str(nMaxIdSeq ))
    Dim countUpto as N
    Dim tableCont as P
    tableCont = table.open("t_contracts")
    'nMaxIdtot = TABLECOUNT("t_contracts","Works_under = "+quote(tableCont.Works_under))

    tableCont.enter_begin()
    nMaxIdtot = TABLECOUNT("t_contracts","Works_under = "+quote(parentform:Worksunder.value))
    tableCont.Idseq = 1
    tableCont.Employee_work = vEmployee
    tableCont.Works_under = vWorksUnder
    tableCont.Contractamt = vContractAmt
    tableCont.idwu = nMaxIdtot
    tableCont.enter_end()
    ' new stuff
    t2 = table.open("t_places")

    '''' Do the following

    Dim passWU as C
    Dim Qry as P
    for countUpto = 1 to nMaxIdSeq step 1
    Qry = tableCont.query_create("N","Employee_work =\"" + vWorksUnder +"\" .And. Idseq = "+Str(countUpto) )
    tableCont.fetch_first()
    nMaxIdtot = TABLECOUNT("t_contracts","Works_under = "+quote(tableCont.Works_under))
    ' ui_msg_box(str(countUpto,4,0),tableCont.Works_under)
    passWU = tableCont.Works_under
    Qry.drop()
    tableCont.enter_begin()
    tableCont.Idseq = countUpto+1
    tableCont.Employee_work = vEmployee
    tableCont.Works_under = passWU
    tableCont.Contractamt = vContractAmt
    tableCont.idwu = nMaxIdtot
    tableCont.enter_end()
    ' new stuff
    t2.enter_begin()
    t2.P_works_under = passwu
    t2.P_employee_work = vEmployee
    t2.enter_end(.t.)
    t2.close()

    next

  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: Need to fill 2 tables with one click

    There is no mention of t_spaces in your post except the line.

    I am not saving any records to table t_spaces. My coding is not working.
    Why would you think the code is not working? Check the t_places table and you should find the added records.
    There can be only one.

Similar Threads

  1. Can you update individual tables in a set form using two or more tables
    By djbriley in forum Alpha Five Version 9 - Desktop Applications
    Replies: 14
    Last Post: 03-04-2009, 10:18 AM
  2. Not all tables shown in dropdown list for ADO Genie when wanting to append tables
    By Sed in forum Alpha Five Version 9 - Desktop Applications
    Replies: 0
    Last Post: 09-04-2008, 06:07 AM
  3. How can exchange datas in tables on button click?
    By Thenmozhi in forum Application Server Version 8
    Replies: 1
    Last Post: 07-19-2007, 12:20 AM
  4. auto fill/fill down
    By Kathryn Breighner in forum Alpha Five Version 4
    Replies: 2
    Last Post: 07-27-2000, 09:55 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
  •