outra9e
21st October 2002, 18:52
I have used a get.first.free.number() function on my unique key field to generate its input. I do not want a user to be able to edit this field manually.

I have used ...

before.input:
get.first.free.number()
attr.input = false

The function works fine but the user can still modify the field!!

I have used the attr.input on another field which has its content generated by a concat statement and the attr.input works fine.

I have tried making the field a display field on the form but the function then no longer works...

Any ideas?

Cheers

evertsen
21st October 2002, 19:09
when the changing to a display field, did you modify the code to reflect this?

before.display:
get.first.free.number()

nick_rogers
21st October 2002, 19:41
what is the choice when you are allowed to edit the field ?
if you are in find mode then the standard program may be over-riding and allowing you to enter a value in the field. Also you have chosed to put the code in the before.input section but this occurs to late to stop the input. I would put it in the before field event, as the before display event would get triggered everytime the field is dislayed (refreshed etc...). Also you might need some code to stop the function from determining a new number each time the event occurs.....

baanprog
21st October 2002, 23:55
I would suggest you should debug and see when its not working.Normally it works, and before.field can NOT be used ,it will get trigerred everytime for every field and your first free number will get a new number.You can make the field display and remove attr.input = false, dont use both there is no meaning.

Hope this helps

outra9e
22nd October 2002, 10:51
Guys

I have tried using the before.display: instead of before.input and then changed the field on the form to display. This works and the field is greyed out, however it does now perform the function everytime the field is refreshed!!

Any ideas on how I can acheive this without this side affect?

As I said before, I have acheived this on a different field, the only differences being that the field is not a unique key and the field is populated by a concat statement as opposed to a function.

Cheers

outra9e
22nd October 2002, 11:03
Guys

I have had almost success...

Using this ....

field.tdsls901.bncdr:
before.input:
get.first.free.number()
If tdsls901.bncdr <> 0 then
attr.input = false
endif


I have stopped the data from being modified, however if the user clicks on the field it does still perform the function. Any ideas on how I can stop this?

Cheers

Ilansu
22nd October 2002, 13:23
if you are using a form type 1 (single occ+main) then you can put your function under the add.set section.

choice.add.set:
before.choice:
get.first.free.number()

field.tdsls901.bncdr:
before.input:
If tdsls901.bncdr <> 0 then
attr.input = false
endif

Ilan S

outra9e
22nd October 2002, 13:57
Ilan

Thank you for this. I have tried it and now the function is not running.

I have the session so that it starts with a new entry.

Anything else that I would need to do?

Cheers

Ilansu
22nd October 2002, 14:58
Andy

if the tdsls901.bncdr is a key field then you can try
declaration:

long flag

field.tdsls901.bncdr:
before.input:
if flag=0 then
get.first.free.number()
flag=1
endif
If tdsls901.bncdr <> 0 then
attr.input = false
endif

main.table.io:
after.write:
flag=0

if it is not a key field why not try
field.tdsls901.bncdr:
before.input:
If tdsls901.bncdr = 0 then
get.first.free.number()
endif
if tdsls901.bncdr<>0 then
attr.input = false
endif

Ilan S

outra9e
22nd October 2002, 16:00
Ilan

Yes this is good, however, if I now press the insert record button, the first free number function is not working...

Cheers

Ilansu
22nd October 2002, 17:28
add this:

choice.add.set:
before.choice:
flag=0

Ilan S