Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert muliple rows

Status
Not open for further replies.

schothorst

Programmer
Aug 26, 2008
30
NL
Hi
I want to insert multipel rows at the same time in a datawindow. Is that possible?
I am using this code right now, but that will only insert one row.
I want to insert as many rows as i choose from a dropdownbox.
thanks
 
What is the code you're currently using?

Can this be accomplished in a simple loop?

Long ll_cnt, ll_row

FOR ll_cnt = 1 TO ddlb_example.TotalItems( )
ll_row = dw_example.InsertRow( 0 )
dw_example.SetItem( ll_row, 'some_column', ddlb_example.Text )
NEXT
 
sorry forgot to insert the code.
I am using just the standart code for inserting a row in a grid or table.
Thanks for you email. I will try this

long ll_row

ll_row = dw_1.InsertRow (0)
dw_1.ScrollToRow(ll_row)
dw_1.SetColumn(1)
dw_1.SetFocus()

cheers
 
Hello
Thanks for your help.
It almost works.

Now it's indeed inserting the number of rows as many as there are items in de ddlb_example
Is is also possible to insert as many rows as I choose in the ddlb_example.

Example:
In the ddlb I choose 4, and than clik insert; that there will be 4 rows inserted (zo instait of the total items in the the ddld, i want the value of the ddlb)

Thanks again for your help sofar
Cheers
 
If you DropDownListBox has nothing but numeric strings as the items (i.e. "1", "2", "3"...), then you should be good-to-go.

In my above example, replace the ddlb_example.TotalItems( ) with Long( ddlb_example.Text ) in the FOR loop.
 
Hello
Yes indeed, that seems to work.
Thanks agian.

The final code for other people became:

Long ll_cnt, ll_row
ll_cnt = 1 TO Long( ddlb_1.Text )
ll_row = dw_1.InsertRow( 0 )
dw_1.SetItem( ll_row, 'proefcode', ddlb_2.Text )
NEXT

happy programming :)
cheers
 
hello
One more question about this topic.
For some reason it will only show about 5 rows in de Dropdown. I tryed to changed this in PB11 but without suc6 .
Somthing is telling me that I have to put this somewhere in the script.
Any idea where and how to put this in?
Thanks alot for you help
Cheers
Ingmar
 
If it's a DropDownListBox, it's the Height property, which I prefer to set at runtime, simply so that in design mode, when I select it, it doesn't take up half the screen.
 
Hi Thekl0wn,
Thanks for all your help. It works perfectly.

My last question...if you don't mind, I am nearly there.
I know it’s possible.

I am using this code (the code you gave me) to insert the amount of chosen rows.
For example let's say I want to insert 5 rows. I choose 5 and 5 rows are being inserted in the table including a value in colom1 that I have been choosing in de bbld_2

***************************script*****************8
Long ll_cnt, ll_row

FOR ll_cnt = 1 TO Long( ddlb_1.Text )
ll_row = dw_2.InsertRow( 0 )

dw_2.SetItem( ll_row, 'colom1', ddlb_2.Text )
NEXT
*************************************************888

I also would like to have the script insert value in ‘colom2’ with the value 1 to 5 in this example.

So for example: if I choose 9 it’s should put in 9 rows, with the choosen value in ddlb_2 in the colom1 and the numbers 1 to 9 in ‘colom2’

So it’s something like dw_2.setitem (ll_row, 'colom1', ddlb_2.Text, ‘colom2’, (1 to long (ddlb_2.Text))

I hope it’s clear and hope you can help me
Thanks very much in advance

Cheers Ingmar
 
I am reading it that you want X rows (X being the Long value selected in ddlb_1) inserted into the DataWindow. And then in column "colom1" you want the value selected in ddlb_2 put into that column. And then in the column "colom2" you want a list of numbers going from 1-to-X, correct? If so:

/*SCRIPT*/
String ls_comma, ls_no_comma
Long ll_cnt, ll_row, ll_count, ll_cumulative

//get rows from DDLB_2
ll_count = Long( ddlb_2.Text ) //number of rows

//build numeric string
FOR ll_cnt = 1 TO ll_count
ls_comma += String( ll_cnt ) //comma-delimited
IF ll_cnt <> ll_count THEN ls_comma += ','

ls_no_comma += String( ll_cnt ) //no commas

ll_cumulative += ll_cnt //cumulative sum
NEXT

//get rows from DDLB_1
ll_count = Long( ddlb_1.Text ) //number of rows

FOR ll_cnt = 1 TO ll_count
ll_row = dw_2.InsertRow( 0 )
dw_2.SetItem( ll_row, 'colom1', ddlb_2.Text )

//use ls_comma, ls_no_comma, cumulative, etc
dw_2.SetItem( ll_row, 'colom2', ls_comma )
NEXT
/*END SCRIPT*/


Let me know if I missed the point entirely. :D
 
Hi

I am not shure if this is correct.
I can not seem to get it to work.

maybe I can make myself more clear:

ddld_1 = nummeric (so I can choose a numver)
ddld_2 = text , letsay 'appel'

so if I choose ddlb_1 number 3 and ddlb_2 'appel'

that I would like to have the following in dw_2

-inserting 3 rows
-in those 3 rows, in collom 1 : 'appel'
-in those 3 rows, in row 1 collom 2 : 1
row 2 collom 2 : 2
row 3 collom 2 : 3

Maybe this helps.
I am struckling with your code, it seems pretty good. It will insert X rows, with 'appel' but not the numbers.

Hope the here from you soon
cheers
Ingmar



 
Inside the FOR..NEXT loop where you set the "collom_1" to "appel", use dw_2.SetItem( ll_cnt, 'collom_2', ll_cnt ) as well. So:

Long ll_cnt, ll_count

//get rows from DDLB_1
ll_count = Long( ddlb_1.Text ) //number of rows

FOR ll_cnt = 1 TO ll_count
ll_row = dw_2.InsertRow( 0 ) //inserts row into dw_2

dw_2.SetItem( ll_row, 'colom1', ddlb_2.Text ) //set colom1 = the text of ddlb_2
dw_2.SetItem( ll_row, 'colom2', ll_cnt ) //set colom2 = the iteration of the FOR..NEXT loop
NEXT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top