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
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
Comment