Peraphs I,m stupid insert into

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Peraphs I,m stupid insert into

Post by sal21 »

I have this loop for next and a table with many fields named CAMPO4, CAMPO5...

Code: Select all


CONTA=4
For I = 17 To 64
If CHECK_B.Range("H" & I) = "X" Then

CONTA = CONTA + 1
End If
Next I

I want to insert the "x" value in a field base a union of CAMPO&conta...
how to?
Last edited by sal21 on 28 May 2010, 06:42, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: PERAPHS I STUPID insert into

Post by HansV »

Into which record do you want to enter the value?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: PERAPHS I STUPID insert into

Post by sal21 »

here...

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: PERAPHS I STUPID insert into

Post by HansV »

Please try to explain more clearly what you want to do.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: PERAPHS I STUPID insert into

Post by sal21 »

HansV wrote:Please try to explain more clearly what you want to do.
In neffect is a dynamic sql query. example.

The for next loop intercept "X" in CONTA=5 and in CONTA=9, dinamiclly create insert into query similar:
insett into mytable (CAMPO5,CAMPO9)values("X","X")

The for next loop intercept "X" in CONTA=5 and in CONTA=9 and in CONTA=11, dinamiclly create insert into query similar:
insett into mytable (CAMPO5,CAMPO9,CAMPO11)values("X","X","X")

In effect CONTA set the right number of field CAMPO (CAMPO&CONTA)

i hope now you undesrtsand me.

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Peraphs I,m stupid insert into

Post by HansV »

Where are these values CONTA=5 etc.?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: Peraphs I,m stupid insert into

Post by sal21 »

HansV wrote:Where are these values CONTA=5 etc.?
CONTA is the counter into the for next loop

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Peraphs I,m stupid insert into

Post by HansV »

And where do we find the "x"?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: Peraphs I,m stupid insert into

Post by sal21 »

The "X" value

If CHECK_B.Range("H" & I) = "X" Then

CONTA = CONTA + 1
End If

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Peraphs I,m stupid insert into

Post by HansV »

Sorry, that doesn't make sense.
Best wishes,
Hans