Apparently this is not a new issue. I am not able to get a form to resynch to the current record at the end of entering a new record. The form is based on a single table and has a button that executes a script that gets a new lead number from a seperate table and adds a new record with this number in the form's table. After the record is added, the form is re-displayed but will not synch to the new record. Below is the code for the button to get a lead number and add a new record:
'Date Created: 18-Jan-2009 11:53:41 AM
'Last Updated: 13-Feb-2009 09:08:30 AM
'Created By : Owner
'Updated By : Al Mondoux
'Get unique sequential Lead number
'02/12/09 Al Mondoux
vTries = 0
form.close()
Start:
on error goto HandleError
dim t as p = table.open("LeadNumbers",FILE_RW_EXCLUSIVE)
dim t1 as p = table.open("Leads")
t1.index_primary_put("Leadno")
dim shared vLNO1 as c
t.fetch_last()
vLNO = t.LeadNoSeq + 1
vLNO1 = left(t.LeadNo,2) + str(vLNO,0)
t.enter_begin()
t.LeadNoSeq = vLNO
t.LeadNo = vLNO1
t.DateOpen = Date()
t.TimeOpen = time("0h:0m:0s:2")
t.enter_end(.t.)
t1.enter_begin()
t1.leadno = t.LeadNo
t1.LeadDate = t.DateOpen
t1.enter_end(.t.)
vleadno = vLNO1
t1.fetch_find(vLeadno)
'f = form.load("Lead")
this.Resynch()
this.show()
this.activate()
goto Done
HandleError:
if vTries < 8
vTries = Vtries + 1
else
goto Retry
end if
goto start
Retry:
vRetry = ui_msg_box("Error","Cannot get Lead Number at this time. Do you want to retry?",ui_yes_no)
if vRetry = ui_yes_selected
vTries = 0
goto Start
else
goto Done
end if
Done:
Any help on this is greatly appreciated.
'Date Created: 18-Jan-2009 11:53:41 AM
'Last Updated: 13-Feb-2009 09:08:30 AM
'Created By : Owner
'Updated By : Al Mondoux
'Get unique sequential Lead number
'02/12/09 Al Mondoux
vTries = 0
form.close()
Start:
on error goto HandleError
dim t as p = table.open("LeadNumbers",FILE_RW_EXCLUSIVE)
dim t1 as p = table.open("Leads")
t1.index_primary_put("Leadno")
dim shared vLNO1 as c
t.fetch_last()
vLNO = t.LeadNoSeq + 1
vLNO1 = left(t.LeadNo,2) + str(vLNO,0)
t.enter_begin()
t.LeadNoSeq = vLNO
t.LeadNo = vLNO1
t.DateOpen = Date()
t.TimeOpen = time("0h:0m:0s:2")
t.enter_end(.t.)
t1.enter_begin()
t1.leadno = t.LeadNo
t1.LeadDate = t.DateOpen
t1.enter_end(.t.)
vleadno = vLNO1
t1.fetch_find(vLeadno)
'f = form.load("Lead")
this.Resynch()
this.show()
this.activate()
goto Done
HandleError:
if vTries < 8
vTries = Vtries + 1
else
goto Retry
end if
goto start
Retry:
vRetry = ui_msg_box("Error","Cannot get Lead Number at this time. Do you want to retry?",ui_yes_no)
if vRetry = ui_yes_selected
vTries = 0
goto Start
else
goto Done
end if
Done:
Any help on this is greatly appreciated.
Comment