jcook331
22nd November 2004, 16:46
I have a session where when the user clicks a button it creates a new record by executing add.set. All of the index fields but one are automatically entered leaving the last one for the user to enter. However, if the user enters a value and then immediately goes to the text editor or tries to save and exit, the value is not saved and a "blank" is written to the table. I have noticed that if you tab first, then there is no problem. Is there a way to force a tab or force the value to be accepted before the save or before the user goes to the text manager?
Thanks
mark_h
22nd November 2004, 17:39
I believe you could just execute(update.db) before either of these events.
Mark
jcook331
22nd November 2004, 17:47
I tried the execute(update.db) and it did not work. It keeps going back to the previous value of the field. I even tried saving the value entered in a temp field and reassigning it to the table field before the execute(update.db) in the before text.manager section and it still didn't work.
thanks
mark_h
22nd November 2004, 18:10
Maybe if you post the code for the session someone will see something. I would expect this to work, but we just need to get it into the correct spot.
Mark
jcook331
22nd November 2004, 18:42
This is the code for the session. The field I am trying to get the session to accept is lflfa345.excd. When you enter a value in this field and go to text manager w/o tabbing, it seems to accept the value and even gets the description for the new code but then immediately replaces it with the old code and brings up the text for the old code rather than asking you to create new text for the new code.
thanks
|****************************** declaration section ***************************
declaration:
table tlflfa345 | Explanations On Closed Production Orders
table tlflfa344
table ttirou001
table ttirou003
extern domain ttyeno txta.yn
extern domain tcorno orno.zoom
extern domain tcopno opno.zoom
extern domain tctano tano.zoom
extern domain tccwoc cwoc.zoom
extern domain tcorno orno.add
extern domain tcopno opno.add
extern domain tctano tano.add
extern domain tccwoc cwoc.add
extern domain tcbool add.code
extern domain tccreg excd.save
before.program:
query.extension = "lflfa345.orno = :orno.zoom and lflfa345.opno = :opno.zoom"
|****************************** table section **********************************
|****************************** zoom section **********************************
zoom.from.all:
on.entry:
import("tisfc010.pdno",orno.zoom)
import("tisfc010.opno",opno.zoom)
import("tisfc010.tano",tano.zoom)
import("tisfc010.cwoc",cwoc.zoom)
add.code = false
lflfa345.orno = orno.zoom
lflfa345.opno = opno.zoom
lflfa345.tano = tano.zoom
lflfa345.cwoc = cwoc.zoom
execute(find.data)
if lflfa345.orno <> orno.zoom or
lflfa345.opno <> opno.zoom then
lflfa345.orno = orno.zoom
lflfa345.opno = opno.zoom
lflfa345.tano = tano.zoom
lflfa345.cwoc = cwoc.zoom
lflfa345.usid = logname$
lflfa345.mdat = date.num()
lflfa345.excd = ""
lflfa345.txta = 0
execute(add.set)
endif
|****************************** form section **********************************
form.all:
init.form:
inputfield.invisible("lflfa345.usid")
inputfield.invisible("lflfa345.mdat")
|****************************** choice section *********************************
choice.end.program:
before.choice:
|***Check to make sure user has entered Explanation Code and Exp. Text
if lflfa345.excd = " " then
message("You must enter a valid Explanation Code before saving record.")
choice.again()
else
if lflfa345.txta = 0 then
message("You must enter Explanatin Text before saving record.")
choice.again()
else
endif
endif
|choice.update.db:
|before.choice:
|commit.transaction()
|choice.mark.delete:
|before.choice:
choice.text.manager:
before.choice:
lflfa345.excd = excd.save
execute(update.db)
|message("%s",lflfa345.excd)
|***Check to make sure user has entered a valid Exp. Code before entering text.
if lflfa345.excd = " " then
message("Please enter a valid Explanation Code before entering Explanation Text.")
choice.again()
endif
|***User choice that allows user to enter a different Explanation Code on the same
|***Production Order and Operation. This option is executed by clicking a button
|***on the form. The first two fields of the index (Order and Operation) are entered
|***automatically (same as the record they are on when they click the button). They
|***must then enter the new Explanation Code and text.
choice.user.0:
after.choice:
orno.add = orno.zoom |lflfa345.orno
opno.add = opno.zoom |lflfa345.opno
tano.add = tano.zoom |lflfa345.tano
cwoc.add = cwoc.zoom |lflfa345.cwoc
lflfa345.orno = orno.add
lflfa345.opno = opno.add
lflfa345.tano = tano.add
lflfa345.cwoc = cwoc.add
add.code = true
execute(add.set)
display("lflfa345.orno")
display("lflfa345.opno")
display("lflfa345.tano")
display("lflfa345.cwoc")
display("lflfa345.excd")
|****************************** field section *********************************
field.lflfa345.orno:
before.input:
lflfa345.orno = orno.zoom
lflfa345.opno = opno.zoom
lflfa345.tano = tano.zoom
lflfa345.cwoc = cwoc.zoom
display("lflfa345.orno")
display("lflfa345.opno")
display("lflfa345.tano")
display("lflfa345.cwoc")
attr.input = false
if add.code then
lflfa345.orno = orno.add
lflfa345.opno = opno.add
lflfa345.tano = tano.add
lflfa345.cwoc = cwoc.add
display("lflfa345.orno")
display("lflfa345.opno")
display("lflfa345.tano")
display("lflfa345.cwoc")
attr.input = false
endif
field.lflfa345.opno:
before.input:
attr.input = false
if add.code then
lflfa345.opno = opno.add
attr.input = false
endif
|***************************************************************************
field.lflfa345.tano:
before.input:
attr.input = false
if add.code then
lflfa345.tano = tano.add
attr.input = false
endif
after.field:
select tirou003.* |***Get Task description
from tirou003
where tirou003._index1 = {:lflfa345.tano}
selectdo
selectempty
tirou003.dsca = ""
endselect
display("tirou003.dsca")
|*************************************************************************
field.lflfa345.cwoc:
before.input:
attr.input = false
if add.code then
lflfa345.cwoc = cwoc.add
attr.input = false
endif
after.field:
select tirou001.* |***Get Work Center description
from tirou001
where tirou001._index1 = {:lflfa345.cwoc}
selectdo
selectempty
tirou001.dsca = ""
endselect
display("tirou003.dsca")
|****************************************************************************
field.lflfa345.excd:
|before.input:
|attr.input = true
when.field.changes:
|***logs the name of the user who entered code and date entered
lflfa345.usid = logname$
lflfa345.mdat = date.num()
check.input:
select lflfa344.*
from lflfa344
where lflfa344._index1 = {:lflfa345.excd}
selectdo
selectempty
message("Invalid Explanation Code!")
set.input.error(" ")
endselect
after.input:
excd.save = lflfa345.excd
after.field:
select lflfa344.* |***Get Explanation Code description
from lflfa344
where lflfa344._index1 = {:lflfa345.excd}
selectdo
selectempty
lflfa344.dsca = ""
endselect
display("lflfa344.dsca")
mark_h
22nd November 2004, 22:54
Have you tried:
choice.add.set:
after.choice:
execute(update.db)
Mark
jcook331
23rd November 2004, 22:49
I tried that as well, but it didn't work. It seems like that if you don't tab through at least one of the first two fields nothing will save. If you click save and exit it blanks out the record or if you click text manager if blanks out the record. I'm not sure what's going on with it.
Thanks
mark_h
24th November 2004, 02:17
Could you try the program without the query.extension? It seems to me I just had a problem with one session I was doing that had query.extension in it. I am not exactly sure how it would work if the order and operation did not exist. Seems to me there was another command you could run that would refresh or re-execute query.extension.
Mark
Ilansu
24th November 2004, 12:27
You are using the query.extension to show only the orders that matches to orno.zoom and opno.zoom but on the other hand you use the add.set if you dont find such a record.
query.extension = "lflfa345.orno = :orno.zoom and lflfa345.opno= :opno.zoom"
If lflfa345.orno <> orno.zoom or lflfa345.opno <> opno.zoom then
You need ( as mark suggested ) to remove the query.extension
Ilan
Hitesh Shah
24th November 2004, 16:00
Baan standard program generates all events for field on tabbing only . So if the user does not tab a key field and saves the record directly ,it's possible the standard program does not have the value user keyed in.
As for generating the tab automatically , there is a way to generate tab programmatically but there is no way program can understand when to generate the tab while user is keying in the data. When user saves the data (before.choice.update.db) , the program does not have the value user just keyed in.
So practically user should press tab himself/herself in such scenario.