Connecting Tech Pros Worldwide Forums | Help | Site Map

Too few parameters

Ronny Sigo
Guest
 
Posts: n/a
#1: Nov 12 '05
Hello all,
On running this code below I get the errmsg: Too few parameters. Expected :
1
[Emailadres] is an existing field in a linked table.
Can anybody see what I do wrong here?
Many thanks
Ronny

Dim dbsMyCheckBase As Database
Dim rst2 As DAO.Recordset
Set dbsMyCheckBase = OpenDatabase("MyPath\MyFile.mdb")
Dim sCheckVar As String
sCheckVar = Nz(Trim(ObjXL.Cells(nRow, nEmailadres).Value))
strSQL = "select * from tblDhscmails where [Emailadres] = sCheckVar"
Set rst2 = dbsMyCheckBase.OpenRecordset(strSQL) '<------------ ERROR LINE
nHowMuchRecs = rst2.RecordCount



Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Too few parameters


On Sun, 2 May 2004 20:53:07 +0200, "Ronny Sigo"
<ronniesigo@skyynet.be> wrote:


Change your code to:
strSQL = "select * from tblDhscmails where [Emailadres] = '" &
sCheckVar & "'"

Otherwise it is looking for the emailaddress "sCheckVar" rather than
"billg@microsoft.com"
Also note I put a single quote around the email address: that way the
query processor knows it's dealing with a string.

-Tom.

[color=blue]
>Hello all,
>On running this code below I get the errmsg: Too few parameters. Expected :
>1
>[Emailadres] is an existing field in a linked table.
>Can anybody see what I do wrong here?
>Many thanks
>Ronny
>
>Dim dbsMyCheckBase As Database
>Dim rst2 As DAO.Recordset
>Set dbsMyCheckBase = OpenDatabase("MyPath\MyFile.mdb")
>Dim sCheckVar As String
>sCheckVar = Nz(Trim(ObjXL.Cells(nRow, nEmailadres).Value))
>strSQL = "select * from tblDhscmails where [Emailadres] = sCheckVar"
>Set rst2 = dbsMyCheckBase.OpenRecordset(strSQL) '<------------ ERROR LINE
>nHowMuchRecs = rst2.RecordCount
>[/color]

Ronny Sigo
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Too few parameters


Thank you Tom, works great :)

"Tom van Stiphout" <tom7744@no.spam.cox.net> schreef in bericht
news:0aqa90hnirr2fe56hbe25i5vtep32toiq3@4ax.com...[color=blue]
> On Sun, 2 May 2004 20:53:07 +0200, "Ronny Sigo"
> <ronniesigo@skyynet.be> wrote:
>
>
> Change your code to:
> strSQL = "select * from tblDhscmails where [Emailadres] = '" &
> sCheckVar & "'"
>
> Otherwise it is looking for the emailaddress "sCheckVar" rather than
> "billg@microsoft.com"
> Also note I put a single quote around the email address: that way the
> query processor knows it's dealing with a string.
>
> -Tom.
>
>[color=green]
> >Hello all,
> >On running this code below I get the errmsg: Too few parameters. Expected[/color][/color]
:[color=blue][color=green]
> >1
> >[Emailadres] is an existing field in a linked table.
> >Can anybody see what I do wrong here?
> >Many thanks
> >Ronny
> >
> >Dim dbsMyCheckBase As Database
> >Dim rst2 As DAO.Recordset
> >Set dbsMyCheckBase = OpenDatabase("MyPath\MyFile.mdb")
> >Dim sCheckVar As String
> >sCheckVar = Nz(Trim(ObjXL.Cells(nRow, nEmailadres).Value))
> >strSQL = "select * from tblDhscmails where [Emailadres] = sCheckVar"
> >Set rst2 = dbsMyCheckBase.OpenRecordset(strSQL) '<------------ ERROR LINE
> >nHowMuchRecs = rst2.RecordCount
> >[/color]
>
>[/color]


Closed Thread