Home » Developer & Programmer » Forms » d2k forms 5.0: Creating multiple items at runtime
d2k forms 5.0: Creating multiple items at runtime [message #83335] Fri, 26 September 2003 01:06 Go to next message
bluebyte
Messages: 25
Registered: September 2003
Junior Member
hi all!
there are 2 number_input items on my form.lets call them num_from & num_to.these have corresponding columns in a table.while doin the data entry, the user shall decide on the no. of sets of the 2 items he/she requires.
eg: if the user wants 2 sets, my form should be able to create num_from1/num_to1, num_from2/num_to2 at runtime.
*the no. of sets 'n' shall be determined at runtime*.

how to implement this?something on the lines of index
arrays used in VB...

pls reply asap.

thnx n regards,
ganga
Re: d2k forms 5.0: Creating multiple items at runtime [message #83336 is a reply to message #83335] Fri, 26 September 2003 03:54 Go to previous messageGo to next message
magnetic
Messages: 324
Registered: January 2003
Senior Member
its easy.
just create lots of text-items in a block.
name them f1,f2..fn.
set the properties to displayed false.
now open your canvas and place the fields on position 0 [[all above eachother]]

now, while running the form, you know how many sets the user want.
create a procedure that will loop to show as many
fields as the input parameter for the sets.

in the procedure, you will also set the x,y positions of the fields.
a poor example: [[ you should examin with x,y positions depending on item width and heigth..]]
user wants 3 sets:

go block ('B');
first item;
l_item:=the name of the first item [[name_in(:system.cursor_item); or get_item_property(name of the item);]]

while v_sets <> input_value loop

set item property(l_item,displayed,true);
set item property(l_item,position,x,y);
l_x:=l_x+ 10;
l_y:=l_y+10;
v_sets:=v_sets+1;
next_item;
l_item:=the name of the next item [[name_in(:system.cursor_item); or get_item_property(name of the item);]]
..
.
end loop;

result should be like:

f1 f2
f3 f4
f5 f6

f1,3,5 --> x pos = 0 ,y pos = 0,5,10
f2,4,6 --> x pos = 10 ,y pos = 0,5,10

its all about dynamically displaying items and put them on the right x,y positions!!

dont forget to set the item_properties to displayed false before you run the above stament. otherwise the items will stay displayed when you run it for the second [[and above]] time in the same session....

good luck.
Re: d2k forms 5.0: Creating multiple items at runtime [message #83340 is a reply to message #83336] Fri, 26 September 2003 08:41 Go to previous messageGo to next message
bluebyte
Messages: 25
Registered: September 2003
Junior Member
hi magnetic!
thnx for the technique...

i hav written a db package which holds a procedure
to insert records from this form into a certain table A.
if the user selects 3 sets, that implies 3 records hav to be inserted into table A...one for each set.
wot should be the form code to support such a procedure?

iam sending item values as parameters to the procedure.
this implies that i should be calling this procedure thrice.

how to loop thro' the block to extract the item values
in case the user input is not known?
(i was thinking of using create_record forms built-in...when the user hits enter key after giving the number in num_to field, the trigger will create new set ...by using this technique, it is not necessary for the user to explicitly state how many sets are required...it is only a matter of hitting enter key if
he/she wants another set.)

thnx n regards,
ganga
Re: d2k forms 5.0: Creating multiple items at runtime [message #83364 is a reply to message #83340] Tue, 30 September 2003 08:12 Go to previous messageGo to next message
magnetic
Messages: 324
Registered: January 2003
Senior Member
your goal is not clear enuff but iwill try to give a hint about your problem with the next example

suppose table A with structure
col1
col2

fileds on forms:
f1 f2
f3 f4
f5 f6

variables:
inputnum=3 [[user wants 3 sets, doenst matter tho]]
v_last number;

all items are on block A
go block ('A');
last_item; navigation to the last item on the block
v2:=last_item;
first_item; navigation to the first item on the block
while not :system.cursor_item=v2 loop
t1=name_in(:system.cursor_item);
next_item;
t2=name_in(:system.cursor_item);
insert into A values(t1,t2);
next_item;
t1:=''; empty the variables for the next set
t2:='';
end loop;
commit_form;
Re: d2k forms 5.0: Creating multiple items at runtime [message #83367 is a reply to message #83364] Tue, 30 September 2003 23:21 Go to previous messageGo to next message
bluebyte
Messages: 25
Registered: September 2003
Junior Member
thnx magnetic!!
tht was the requirement!

btw, am finding difficulty in creating new sets of txt
items on pressing *enter* key...

wud u pls walk me thro'...
Re: d2k forms 5.0: Creating multiple items at runtime [message #84293 is a reply to message #83335] Wed, 25 February 2004 17:41 Go to previous message
jigs
Messages: 1
Registered: February 2004
Junior Member
hey can anyone tell me how can we create a table from d2k on the press of a button by entering the tablename in the textfield.
Previous Topic: Access Collection data on Forms canvas
Next Topic: Urgent !How to find Reports Server Name in Forms9i/Reports9i
Goto Forum:
  


Current Time: Thu Apr 25 09:25:28 CDT 2024