dbTalk Databases Forums  

Problem inserting new record

comp.databases.paradox comp.databases.paradox


Discuss Problem inserting new record in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rey
 
Posts: n/a

Default Problem inserting new record - 09-11-2006 , 08:46 PM






Howdy all.

Got a form opened by another form.

My problem is related to inability to cause a record to be
added/appended after the last record in a tableframe via via code using
insertafterrecord or via insert key. ui table frame has properties of
autoappend true and autofit false.

Every effort resulted in record being added before last record...it
seemed as if I could not add to end of table but was able to add/insert
new record via insert key to top of table...

Then got idea to attach a tcursor to the tableframe(escrFees) but still
nothing until I added space to the description field then it displayed
the new record at en of table and I was add to add data.

Question is why couldn't I add a new record? If I opened form by itself
- not called by another form - I had no problems adding record via
insert key.

Appreciate you comments/suggestion.

Thanks,
Rey

*************************
pushbutton code
var
uifees uiObject
tc tcursor
endvar

escrFees.edit()
; attach tcursor to uiobject
tc.attach(escrFees)
tc.edit()
tc.end()
tc.insertAfterRecord()
tc.description = " "
; tc.endedit()

uiFees.attach("escrFees")
uiFees.action(dataEnd)
;uiFees.insertAfterRecord()
uiFees.UnitNum.MoveTo()
uiFees.forcerefresh()

if tc.isassigned() then
tc.close()
endif


Reply With Quote
  #2  
Old   
Tony McGuire
 
Posts: n/a

Default Re: Problem inserting new record - 09-11-2006 , 10:45 PM







What code is on the form?

Could be lots of places code could be acting to prohibit various actions.

Event level, key level, record level, form level etc etc etc.

---------------------------------------------------------
Tony McGuire
http://www.westjordandogpark.com



Reply With Quote
  #3  
Old   
Rey
 
Posts: n/a

Default Re: Problem inserting new record - 09-12-2006 , 01:21 AM



Tony McGuire wrote:
Quote:
What code is on the form?

Howdy Tony.

Code on form (escrTrans.fsl) follows. Form called from open not
openAsDialog.
Thanks for assisting.

Rey

;|BeginMethod|#FormData1|Var|
Var

frmUnit form ; open MastUnit form
strUnit string ; unitnum
uiUnitNum uiobject ; unitnumPK field on MastUnit form
lDone logical ; rpt data obtained


endVar

;|EndMethod|#FormData1|Var|
;|BeginMethod|#FormData1|init|
method init(var eventInfo Event)
; attach to Unit Master (MastUnit)
; get unitnum


IF NOT frmUnit.attach("Unit Master") THEN
errorshow("Unable to attach to Unit Master form", "Press >> button
if displayed")
msgInfo("","Unable to attach to Unit Master form")
RETURN
endIF

txtUnit.edit()
txtUnit.blank()


; get unit number
uiUnitNum.attach(frmUnit.unitnumpk)
strUnit = uiUnitNum.value
txtUnit.value = uiUnitNum.value


endMethod

;|EndMethod|#FormData1|init|
;|BeginMethod|#Page2|open|
method open(var eventInfo Event)
; place tableframe into edit mode so user can click on Match
column...
escrFees.edit()
if escrfees.isedit() then
message("escrFees UIObject in edit mode")
; msginfo("","escrFees UIObject in edit mode")
endIF

lDone = false ; flag for what to return to calling form


endMethod

;|EndMethod|#Page2|open|
;|BeginMethod|#Page2.btnAdd|pushButton|
method pushButton(var eventInfo Event)
{
insert new record
currently unable to move to end of table and do so
even with autoappend true and autofit false
getting to be pain...
}

var
uifees uiObject
tc tcursor
endvar

escrFees.edit()
; attach tcursor to uiobject
tc.attach(escrFees)
tc.edit()
tc.end()
tc.insertAfterRecord()
tc.description = " "

uiFees.attach("escrFees")
uiFees.action(dataEnd)
;uiFees.insertAfterRecord()
uiFees.forcerefresh()
uiFees.UnitNum.MoveTo()

if tc.isassigned() then
tc.close()
endIF

endMethod

;|EndMethod|#Page2.btnAdd|pushButton|
;|BeginMethod|#Page2.btnCancel|pushButton|
method pushButton(var eventInfo Event)


; form closed by calling form MastUnit
formReturn("Cancel")

endMethod

;|EndMethod|#Page2.btnCancel|pushButton|
;|BeginMethod|#Page2.btnTrans|pushButton|
method pushButton(var eventInfo Event)
; get matched escrow fees and those that are unposted

VAR
sqlPosted SQL
sqlUnPosted SQL
dbPriv database
uiFees uiObject ; escrFees table frame
uiMatched uiObject ; matched ui object
frmSelf form ; this form
siChecked smallint ; # check boxes checked
liNumRecs longint ; # records in table frame
x longint ; counter
tbl table
arTables Array[2] string ; hold tables being indexed
endVAR

siChecked = 0
liNumRecs = 0

frmSelf.attach()

uiFees.attach(frmSelf.EscrFees)

liNumRecs = uiFees.nRecords()

uiFees.home() ; go to 1st record

; now loop/move thru tblframe records seeing which records are
checked
FOR X FROM 1 TO liNumRecs

if uiFees.Posted.value = "P" then
siChecked = siChecked + 1
endIF

uiFees.nextRecord()

endFor

; info user if nothing checked
IF siChecked = 0 THEN
IF msgQuestion("", "You did NOT match any escrow fees." + "\n"
+ "Is this correct?") = "Yes" THEN
; lDone = false ; flag for what to return to calling form
btnExit.moveto()
RETURN
ELSE
uiFees.moveto()
uiFees.home()
RETURN
endIF
endIF


IF NOT dbPriv.open("riv:") THEN
errorshow("", "Click >> button if displayed")
msgstop("","Unable to access private directory to run querys." +
"\n"
+ "Notify Systems Adminstration")
RETURN
endIF

sqlPosted = SQL

select unitnum,
itemcode,
description,
prepaid,
amount
from escrfees
where Posted = 'P'
order by ItemCode

endSQL

sqlPosted.writeSQL("riv:sqlPosted.txt")

IF NOT sqlPosted.executeSQL(dbPriv, "riv:FeesPosted.db") THEN
errorshow("Unable to run Posted Fees query", "Click >> if
displayed")
msgstop("Query Problem", "Unable to run Posted Fees query")
lDone = False
RETURN
endIF


sqlunPosted = SQL

select unitnum,
itemcode,
description,
prepaid,
amount
from escrfees
where Posted = ''
order by ItemCode

endSQL

sqlunPosted.writeSQL("riv:sqlunPosted.txt")

IF NOT sqlunPosted.executeSQL(dbPriv, "riv:FeesNotPosted.db") THEN
errorshow("Unable to run Posted Fees query", "Click >> if
displayed")
msgstop("Query Problem", "Unable to run Posted Fees query")
lDone = False
RETURN
endIF

; now add the indexs to link rpt tables
arTables[1] = "riv:FeesPosted.db"
arTables[2] = "riv:FeesNotPosted.db"

FOR X FROM 1 to arTables.size()
tbl.attach(arTables[X])

INDEX tbl
PRIMARY
ON "UnitNum", "ItemCode", "Description"
ENDINDEX
endFor

tbl.unattach()

msginfo("","Completed getting fees and transaction for report.")

; finally
lDone = True

btnexit.moveto()

endMethod

;|EndMethod|#Page2.btnTrans|pushButton|
;|BeginMethod|#Page2.btnChecked|pushButton|
method pushButton(var eventInfo Event)
; test of counting whether check box is checked
; instead of adding field to tbl...


VAR
uiFees uiObject ; escrFees table frame
uiMatched uiObject ; matched ui object
frmSelf form ; this form
siChecked smallint ; # check boxes checked
liNumRecs longint ; # records in table frame
x longint ; counter

endVAR

siChecked = 0
liNumRecs = 0

frmSelf.attach()

uiFees.attach(frmSelf.EscrFees)
uiMatched.attach(uiFees.Posted.btnPosted)

liNumRecs = uiFees.nRecords()

uiFees.home() ; go to 1st record

; now loop/move thru tblframe records seeing which records are
checked
FOR X FROM 1 TO liNumRecs

if uiFees.Posted.value = "P" then
siChecked = siChecked + 1
endIF

uiFees.nextRecord()

endFor

siChecked.view("# Checked")



endMethod

;|EndMethod|#Page2.btnChecked|pushButton|
;|BeginMethod|#Page2.EscrFees.#Record9.Posted|chan geValue|
method changeValue(var eventInfo ValueEvent)
var
fldvalue string ; current field value
endvar
{
fldvalue = self.value
;view("changevalue - current")
;message("ChangeValue field value = " + strval(fldvalue))

;sleep(1000)

; add as this assn being selected for purge
if (fldvalue = "") THEN
self.value = "M"
dodefault
; self.view("self changed to M")
; NumSelected = NumSelected + 1
; Assncount.value = NumSelected
endif

; subtract since user made change
if fldvalue = "M" then
fldvalue.blank()
self.value = blank()
dodefault
; self.view("self changed to blank")
{if NOT (NumSelected = 0) THEN
NumSelected = NumSelected - 1
Assncount.value = NumSelected
endif
}
;endif

endMethod

;|EndMethod|#Page2.EscrFees.#Record9.Posted|change Value|
;|BeginMethod|#Page2.EscrFees.#Record9.Posted|newV alue|
method newValue(var eventInfo Event)
; cause value to be committed
; new value coming into fld

var
;currentval string ; new value cominng to field
endvar


;incoming = eventinfo.newvalue()
; doDefault

if eventinfo.reason() = EditValue then
;currentval = self.value
;view(currentval)
;message("New value Self value = " + strVal(currentVal))
;sleep(1000)
dodefault
;self.action(editCommitField)
self.action(dataUnlockRecord)
;action(FieldForward)
endIF

endMethod

;|EndMethod|#Page2.EscrFees.#Record9.Posted|newVal ue|
;|BeginMethod|#Page2.btnExit|pushButton|
method pushButton(var eventInfo Event)

; form closed by calling form MastUnit
; flag lDone = true finished getting rpt data
IF lDone THEN
formReturn("OK")
ELSE
formReturn("Cancel")
endIF

endMethod

;|EndMethod|#Page2.btnExit|pushButton|



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.