Concatenate recordset

abev107
01-09-2004, 08:40 AM
Is this possible:


rs.addnew
For z = 1 To UBound(vLineScore)
test = rs!ctlInn & z
test = vLineScore(z)
Next
rs.update


My problem is 'rs!ctlInn' could be anywhere from 10 to 18 columns. So I need to somehow exit out of the 'addnew' when it ends. So I tried to concatenate but that puts quotes in 'test'. Is there a way to concatenate the subscript 'z' with the recordset?

Shurik12
01-09-2004, 08:43 AM
Hi,

I hope I follow you, you mean

test = rs!ctlInn(z) ?


Regards,
Shurik.

abev107
01-09-2004, 08:52 AM
Hi,

I hope I follow you, you mean

test = rs!ctlInn(z) ?


Regards,
Shurik.

the fields look like this:

rs!ctlInn1
rs!ctlInn2
..etc

what I need to do is increment ctlInn'z' without quotes or parens so as I loop thru the for...next it looks like:
rs!ctlInn1 = vLinescore(1)
rs!ctlInn2 = vLinescore(2)
etc...

thanks shurik

Dennis DVR
01-09-2004, 09:00 AM
Hi,

I hope I follow you, you mean

test = rs!ctlInn(z) ?


Regards,
Shurik.

the fields look like this:

rs!ctlInn1
rs!ctlInn2
..etc

what I need to do is increment ctlInn'z' without quotes or parens so as I loop thru the for...next it looks like:
rs!ctlInn1 = vLinescore(1)
rs!ctlInn2 = vLinescore(2)
etc...

thanks shurik

can you give us an example output of this field?
coz if is a number you could just convert it to numeric using the val or other convertion function if is a string there;s no need to remove the single quote.

Shurik12
01-09-2004, 09:05 AM
you'll be better off not using the fields names but indexes

rs.Fields(i).Value = vLinescore(i)

in this case I don't really see a need for doing concatenation.

abev107
01-09-2004, 09:08 AM
you'll be better off not using the fields names but indexes

rs.Fields(i).Value = vLinescore(i)

in this case I don't really see a need for doing concatenation.

The problem with using fields is the recordset from the table are more than this series of data I am trying to update. For example, their are 30 fields in this table, the first 12 are other data, then the next 18 are ctlInn1 through ctlInn18.

Can I skip fields with rs.fields?

Dennis DVR
01-09-2004, 09:13 AM
you'll be better off not using the fields names but indexes

rs.Fields(i).Value = vLinescore(i)

in this case I don't really see a need for doing concatenation.

The problem with using fields is the recordset from the table are more than this series of data I am trying to update. For example, their are 30 fields in this table, the first 12 are other data, then the next 18 are ctlInn1 through ctlInn18.

Can I skip fields with rs.fields?

what's in the vlinescore?
and why did you start your for loops to 1 if you don't need the other fields? :confused:

Shurik12
01-09-2004, 09:18 AM
I just found this thread by you..

http://www.visualbasicforum.com/showthread.php?t=133455

isn't it about the same?

abev107
01-09-2004, 09:52 AM
I just found this thread by you..

http://www.visualbasicforum.com/showthread.php?t=133455

isn't it about the same?

thanks shurik, that gets me mostly where I want to go. I know you posted that before, but I did something to not make it work. Sorry for the runaround.

The next problem I have is I will not always have as many subscripts as I do fields.

For example I have fields for 18 innings (ctlInn1 thru ctlInn18) but if the game only lasts 9 innings, I will only have an array with 9 subscripts, and the code I wrote loops thru and trys to add 18 subscripts to I get a subscript out of range. Is there a way to exit the For..Next when I run out of subscripts?

Dennis DVR
01-09-2004, 09:57 AM
I just found this thread by you..

http://www.visualbasicforum.com/showthread.php?t=133455

isn't it about the same?

thanks shurik, that gets me mostly where I want to go. I know you posted that before, but I did something to not make it work. Sorry for the runaround.

The next problem I have is I will not always have as many subscripts as I do fields.

For example I have fields for 18 innings (ctlInn1 thru ctlInn18) but if the game only lasts 9 innings, I will only have an array with 9 subscripts, and the code I wrote loops thru and trys to add 18 subscripts to I get a subscript out of range. Is there a way to exit the For..Next when I run out of subscripts?

first your array should be redim base on innings i.e
Redim vLineScore(innings - 1)

second use the for loop should only iterate according to the size of your vLineScore i.e
for i = 0 to ubound(vLineScore) - 1
next

abev107
01-09-2004, 10:19 AM
thanks duane and shurik, you guys are a big help.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum