Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Too few Parameters, expected 1 err 3061

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johnny Bright - 29 Nov 2005 21:40 GMT
I'm trying to run this code to set a form's recordsource.  I've tried this
code both in the open and load events.  intTot is actually a number field
whose format is byte.  Am I missing a quote somewhere or what's wrong?

Thanks for all help offered!

JR
Dim db As Database
   Dim rst As Recordset

   Set db = CurrentDb()
   Set rst = db.OpenRecordset("select * from tblTaxIndicators where intTot
= " & _
   1, dbOpenSnapshot)

   If rst.RecordCount = 1 Then
       Me.RecordSource = "qryDD"
   Else
       Me.RecordSource = "qryDDTot"
   End If

   Set db = Nothing
   Set rst = Nothing
Signature

www.brightfuture.ca/bright
My email address can be found on my site.

OfficeDev18 - 29 Nov 2005 22:38 GMT
Change          Me.RecordSource = "qryDD"  to           Me.RecordSource =
CurrentDb.QueryDefs("qryDD")

Change the other statement similarly.

>I'm trying to run this code to set a form's recordsource.  I've tried this
>code both in the open and load events.  intTot is actually a number field
[quoted text clipped - 19 lines]
>    Set db = Nothing
>    Set rst = Nothing

Signature

Sam

Klatuu - 29 Nov 2005 22:59 GMT
The previous answer is not the problem.  It is a syntax error, I think.  
Should be
Set rst = db.OpenRecordset("select * from tblTaxIndicators where intTot =  
1;" , dbOpenSnapshot)

You would only need to move the 1 outside the qoutes if it were a variable
or control you were referencing, for example
x = 1
Set rst = db.OpenRecordset("select * from tblTaxIndicators where intTot =  "
& x & ";" , dbOpenSnapshot)

Now, there is a simpler way to get what you want, I think.  If you expect to
return either any record where intTot =1 or no records, then this approach
will work:

   If IsNull(DLookup("[intTot]","tblTaxIndicators","[intTot] = 1")) Then
       Me.RecordSource = "qryDDTot"
   Else
       Me.RecordSource = "qryDD"
   End If

> I'm trying to run this code to set a form's recordsource.  I've tried this
> code both in the open and load events.  intTot is actually a number field
[quoted text clipped - 19 lines]
>     Set db = Nothing
>     Set rst = Nothing
Johnny Bright - 30 Nov 2005 00:37 GMT
Thanks to all who replied!  Klatuu, that worked great!  It will be a lot
easier to code than dealing with the query coding.

Thanks for your great advice!

JR
Signature

www.brightfuture.ca/bright
My email address can be found on my site.

> The previous answer is not the problem.  It is a syntax error, I think.  
> Should be
[quoted text clipped - 40 lines]
> >     Set db = Nothing
> >     Set rst = Nothing
Douglas J. Steele - 29 Nov 2005 23:28 GMT
Another possibility is that your declaration of the recordset is incorrect.

Assuming you're using Access 2000 or 2002, you obviously have added a
reference to DAO, or else Dim db As Database would raise an error. However,
if you didn't remove the reference to ADO, your declaration for rst is
incorrect. If you have both references, you'll find that you'll need to
"disambiguate" certain declarations, because objects with the same names
exist in the 2 models. For example, to ensure that you get a DAO recordset,
you'll need to use Dim rst as DAO.Recordset (to guarantee an ADO recordset,
you'd use Dim rst As ADODB.Recordset)  I have seen the "Too few parameters"
message under this condition.

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> I'm trying to run this code to set a form's recordsource.  I've tried this
> code both in the open and load events.  intTot is actually a number field
[quoted text clipped - 19 lines]
>    Set db = Nothing
>    Set rst = Nothing
KRose - 30 Nov 2005 02:59 GMT
Johnny,

Try the following code for your set recordset statement.

   Set rst = db.OpenRecordset("select * from tblTaxIndicators where
intTot = 1", dbOpenSnapshot)

In essence, include the 1 inside the statement.  If you wish to have
the criteria expressed as a variable, you would need it outside the
quotes, but as a literal, including it in the statement is the way to
go.  This is a bit deceiving since 1 is an int vs. a string.

Hope this helps,
Kevin

> I'm trying to run this code to set a form's recordsource.  I've tried
> this code both in the open and load events.  intTot is actually a
[quoted text clipped - 20 lines]
>     Set db = Nothing
>     Set rst = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.