Solved

Too Few Parameters. Expected 2

Posted on 2011-09-14
4
307 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

920 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now