Solved

Too Few Parameters. Expected 2

Posted on 2011-09-14
4
312 Views
Last Modified: 2012-08-13
- Hi, before posting here, I have done by research. According to different solutions to this error, my code looks good.

When this code is run, the form is open (where variable is derived) and populated. The table "INTER" exists under 'Tables'
The same code worked upto this point > & " AND TCOMBI.SERVICE=" & Chr(34) & [Forms]![Point2Point]![servicecombo] & Chr(34) & " ORDER BY INTER.CLASS, dbFailOnError

Open in new window


After adding extra variable (above) the code stopped working and gave me the error. Upon the error, a quote was automatically added to the end of the statement (I didn't add it but I suspect this is the culprit)

CurrentDb.Execute "SELECT INTER.OTCOMBO INTO getT FROM INTER WHERE INTER.TCOMBO=" & Chr(34) & termcombo & Chr(34) & " AND TCOMBI.SERVICE=" & Chr(34) & [Forms]![Point2Point]![servicecombo] & Chr(34) & " ORDER BY INTER.CLASS, dbFailOnError

Open in new window


Any help is much appreciated!
0
Comment
Question by:Shanan212
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 36539598
Add a quote before the ",dbfailonerror":


CurrentDb.Execute "SELECT INTER.OTCOMBO INTO getT FROM INTER WHERE INTER.TCOMBO=" & Chr(34) & termcombo & Chr(34) & " AND TCOMBI.SERVICE= " & Chr(34) & [Forms]![Point2Point]![servicecombo] & Chr(34)  & "  ORDER BY INTER.CLASS", dbFailOnError 

Open in new window

0
 
LVL 13

Author Comment

by:Shanan212
ID: 36542735
Ow that worked to eliminate one error. Now its giving me too few parameters: Expected 1

Thanks!
0
 
LVL 13

Author Closing Comment

by:Shanan212
ID: 36542816
Able to solve 1 error
0
 
LVL 57
ID: 36543018
When you reference a form control, it must be a full reference:

CurrentDb.Execute "SELECT INTER.OTCOMBO INTO getT FROM INTER WHERE INTER.TCOMBO=" & Chr(34) & termcombo & Chr(34) & " AND TCOMBI.SERVICE=" & Chr(34) & [Forms]![Point2Point]![servicecombo] & Chr(34) & " ORDER BY INTER.CLASS, dbFailOnError

 termcombo is not a full reference.  Must be something like:

  Forms![<form name>]![termcombo]

  Just like your other one for servicecombo.

Jim.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Calculate Time acces 2010 12 30
DSN-LESS connection to MS Access database 6 32
VBA SQL statement - 2 "OR"s and 1 "And" 4 27
aggregate query? 20 53
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question