Re: SQL syntax
- From: Jason Keats <jkeats@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 02 May 2009 12:02:32 +1000
Edward wrote:
Hello
I'm receiving a 'Too Few Perameters. expected 1' error when trying to use a variable in place of a number in a Where statemet of an SQL string.
------ code
Private Sub cmdOutput_Click(Index As Integer)
Dim DB As Database, RS As DAO.Recordset
strSQL = "SELECT tblOutPoints.ID, tblOutPoints.Bit_No, tblOutPoints.Bank_No " & _
"FROM tblOutPoints " & _
"WHERE tblOutPoints.ID = Index;"
' "WHERE tblOutPoints.ID = 2;"
Set DB = OpenDatabase(StoredDataPath)
Set RS = DB.OpenRecordset(strSQL)
MsgBox RS!Time_Msec
------ end code
The second commented Where using a numeral 2 works perfect. Access creates a string as follows: WHERE (((tblOutPoints.ID)="Index"));
however it also fails.
Any suggestions appreciated.
PS: I'm looking for an Access-based SQL syntax checker/corrector that one of the MVPs referred me to a few years back. May have been Douglas Steele.
Replace
"WHERE tblOutPoints.ID = Index;"
with
"WHERE tblOutPoints.ID = " & Index & ";"
HTH
.
- Follow-Ups:
- Re: SQL syntax
- From: Edward
- Re: SQL syntax
- References:
- SQL syntax
- From: Edward
- SQL syntax
- Prev by Date: SQL syntax
- Next by Date: Re: SQL syntax
- Previous by thread: SQL syntax
- Next by thread: Re: SQL syntax
- Index(es):
Relevant Pages
|