for ... next statement and recordsets problems

  • Thread starter Thread starter CristianTCDM
  • Start date Start date
C

CristianTCDM

Hello ,

I am trying to obtain a recordset for every value in a certain field and I
used the following lines of code :

For i = 1 To intINDmax

intI = i
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

....

Next i

I got the message : too few parameters . expected 1
Is it the syntax ? Should I parametrise in other way ?

Thanks for any suggestion .
 
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =

It looks like you have intI as part of a string rather than the value. Try
this:

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

(I added the line breaks " _" for ease of reading)



--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


CristianTCDM said:
Hello ,

I am trying to obtain a recordset for every value in a certain field and I
used the following lines of code :

For i = 1 To intINDmax

intI = i
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

...

Next i

I got the message : too few parameters . expected 1
Is it the syntax ? Should I parametrise in other way ?

Thanks for any suggestion .
 
Correction (I forgot the closing parethese):
Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

s/b

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI & ")"


--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


dymondjack said:
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

It looks like you have intI as part of a string rather than the value. Try
this:

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

(I added the line breaks " _" for ease of reading)



--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


CristianTCDM said:
Hello ,

I am trying to obtain a recordset for every value in a certain field and I
used the following lines of code :

For i = 1 To intINDmax

intI = i
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

...

Next i

I got the message : too few parameters . expected 1
Is it the syntax ? Should I parametrise in other way ?

Thanks for any suggestion .
 
Correction AGAIN (i put the parenthese as part of the SQL statement rather
than the argument (its a wonder I get anything done)):
Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI & ")"

s/b

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI)


There... that should do it.. finally

--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


dymondjack said:
Correction (I forgot the closing parethese):
Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

s/b

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI & ")"


--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


dymondjack said:
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

It looks like you have intI as part of a string rather than the value. Try
this:

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

(I added the line breaks " _" for ease of reading)



--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


CristianTCDM said:
Hello ,

I am trying to obtain a recordset for every value in a certain field and I
used the following lines of code :

For i = 1 To intINDmax

intI = i
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

...

Next i

I got the message : too few parameters . expected 1
Is it the syntax ? Should I parametrise in other way ?

Thanks for any suggestion .
 
Yes , it works ,

Thanks a lot
dymondjack said:
Correction AGAIN (i put the parenthese as part of the SQL statement rather
than the argument (its a wonder I get anything done)):
Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI & ")"

s/b

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI)


There... that should do it.. finally

--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


dymondjack said:
Correction (I forgot the closing parethese):
Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

s/b

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI & ")"


--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


dymondjack said:
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

It looks like you have intI as part of a string rather than the value. Try
this:

Set rstQ = dbs.OpenRecordset( _
"SELECT * FROM MedConcat " & _
"WHERE [IDindrp] = " & intI

(I added the line breaks " _" for ease of reading)



--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery


:

Hello ,

I am trying to obtain a recordset for every value in a certain field and I
used the following lines of code :

For i = 1 To intINDmax

intI = i
Set rstQ = dbs.OpenRecordset("SELECT * FROM MedConcat WHERE [IDindrp] =
intI ")

...

Next i

I got the message : too few parameters . expected 1
Is it the syntax ? Should I parametrise in other way ?

Thanks for any suggestion .
 
Back
Top