PC Review


Reply
 
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      17th Mar 2006
I am having an error code come up saying Run Time Error '3061' Too few
parameters. Expected 1

This error shows me my execute statement:
db.execute strSQL, dbFailOnError.

I have defined by db as CurrentDb already. I am trying to execute my Insert
Into statement which is the variable strSQL.
Please help anyone.....
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      17th Mar 2006
"amy14775" <(E-Mail Removed)> wrote in message
news:7B7B366A-E449-4AF3-B91F-(E-Mail Removed)
> I am having an error code come up saying Run Time Error '3061' Too few
> parameters. Expected 1
>
> This error shows me my execute statement:
> db.execute strSQL, dbFailOnError.
>
> I have defined by db as CurrentDb already. I am trying to execute my
> Insert Into statement which is the variable strSQL.
> Please help anyone.....


You'll get that message when the SQL string contains an unresolved
parameter, or an unrecognized word that the query engine construes as a
parameter. Does your SQL string contain a reference to a control on a
form? If so, DAO won't recognize it and fill it in automatically.
Usually, your best solution to this problem is to build the value of the
control into the string, rather than a reference to the control.

What's the value of strSQL, and what does the surrounding code look
like?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      20th Mar 2006

Dirk,
This is the code for the calculation button. I am trying to populate a table
with records that are calculated from this code. Basically it will loop
through and give me 12 dates in the future that will be seperate records in
my other table. The string is my Insert Into code. The values in the code
will partly be what the user enters on the form and part what the code
calculates for the dates needed in the future. But like I said previously, I
keep getting the parameter message. Any help you can give would be so greatly
appreciated. It is one of those I had to get up for a little while and walk
away. So a fresh set of eyes would be most helpful.
Thank you,
Amy



Private Sub cmdCalcWeek_Click()
Dim db As DAO.Database
Dim intCounter As Integer
Dim dteTest As Date
Dim dteStart As Date
Dim strSql As String

Set db = CurrentDb
dteStart = Me.txtStart

For intCounter = 1 To 12 Step 1
dteTest = DateAdd("d", 7, dteStart)
strSql = "Insert Into Test(SocialSecurity,StartDate,TestType,DateDue)" &
"Values('" & Me.txtSocialSecurity & "', #" & Me.txtStart & "#, " &
Me.lstTestType & ", #" & dteTest & "#)"

db.Execute strSql, [dbFailOnError]
dteStart = dteTest
Next intCounter

Set db = Nothing

"Dirk Goldgar" wrote:

> "amy14775" <(E-Mail Removed)> wrote in message
> news:7B7B366A-E449-4AF3-B91F-(E-Mail Removed)
> > I am having an error code come up saying Run Time Error '3061' Too few
> > parameters. Expected 1
> >
> > This error shows me my execute statement:
> > db.execute strSQL, dbFailOnError.
> >
> > I have defined by db as CurrentDb already. I am trying to execute my
> > Insert Into statement which is the variable strSQL.
> > Please help anyone.....

>
> You'll get that message when the SQL string contains an unresolved
> parameter, or an unrecognized word that the query engine construes as a
> parameter. Does your SQL string contain a reference to a control on a
> form? If so, DAO won't recognize it and fill it in automatically.
> Usually, your best solution to this problem is to build the value of the
> control into the string, rather than a reference to the control.
>
> What's the value of strSQL, and what does the surrounding code look
> like?
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      20th Mar 2006
"amy14775" <(E-Mail Removed)> wrote in message
news:6168429D-BCBF-4634-9100-(E-Mail Removed)
> Dirk,
> This is the code for the calculation button. I am trying to populate
> a table with records that are calculated from this code. Basically it
> will loop through and give me 12 dates in the future that will be
> seperate records in my other table. The string is my Insert Into
> code. The values in the code will partly be what the user enters on
> the form and part what the code calculates for the dates needed in
> the future. But like I said previously, I keep getting the parameter
> message. Any help you can give would be so greatly appreciated. It is
> one of those I had to get up for a little while and walk away. So a
> fresh set of eyes would be most helpful.
> Thank you,
> Amy
>
>
>
> Private Sub cmdCalcWeek_Click()
> Dim db As DAO.Database
> Dim intCounter As Integer
> Dim dteTest As Date
> Dim dteStart As Date
> Dim strSql As String
>
> Set db = CurrentDb
> dteStart = Me.txtStart
>
> For intCounter = 1 To 12 Step 1
> dteTest = DateAdd("d", 7, dteStart)
> strSql = "Insert Into
> Test(SocialSecurity,StartDate,TestType,DateDue)" & "Values('" &
> Me.txtSocialSecurity & "', #" & Me.txtStart & "#, " & Me.lstTestType
> & ", #" & dteTest & "#)"
>
> db.Execute strSql, [dbFailOnError]
> dteStart = dteTest
> Next intCounter
>
> Set db = Nothing


Make sure that "Test" is really the name of your table, and that
"SocialSecurity", "StartDate", "TestType", and "DateDue" are really the
names of fields in that table -- check the exact spellings. Also, check
that TestType is a numeric field, and that the bound column of
lstTestType contains numeric values.

If I were writing this, I'd put a space into the SQL string before the
"Values" keyword for clarity, but that isn't actually required in this
case because the closing parenthesis is a sufficient delimiter.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      20th Mar 2006
The names are all correct. But the TestType field is a text field with the
name of the test needed in it. The same goes for the list boxes. Is this what
is causing the problem?If so do you know the direction I need to go to fix
it. I appreciate all the time and help.

"Dirk Goldgar" wrote:

> "amy14775" <(E-Mail Removed)> wrote in message
> news:6168429D-BCBF-4634-9100-(E-Mail Removed)
> > Dirk,
> > This is the code for the calculation button. I am trying to populate
> > a table with records that are calculated from this code. Basically it
> > will loop through and give me 12 dates in the future that will be
> > seperate records in my other table. The string is my Insert Into
> > code. The values in the code will partly be what the user enters on
> > the form and part what the code calculates for the dates needed in
> > the future. But like I said previously, I keep getting the parameter
> > message. Any help you can give would be so greatly appreciated. It is
> > one of those I had to get up for a little while and walk away. So a
> > fresh set of eyes would be most helpful.
> > Thank you,
> > Amy
> >
> >
> >
> > Private Sub cmdCalcWeek_Click()
> > Dim db As DAO.Database
> > Dim intCounter As Integer
> > Dim dteTest As Date
> > Dim dteStart As Date
> > Dim strSql As String
> >
> > Set db = CurrentDb
> > dteStart = Me.txtStart
> >
> > For intCounter = 1 To 12 Step 1
> > dteTest = DateAdd("d", 7, dteStart)
> > strSql = "Insert Into
> > Test(SocialSecurity,StartDate,TestType,DateDue)" & "Values('" &
> > Me.txtSocialSecurity & "', #" & Me.txtStart & "#, " & Me.lstTestType
> > & ", #" & dteTest & "#)"
> >
> > db.Execute strSql, [dbFailOnError]
> > dteStart = dteTest
> > Next intCounter
> >
> > Set db = Nothing

>
> Make sure that "Test" is really the name of your table, and that
> "SocialSecurity", "StartDate", "TestType", and "DateDue" are really the
> names of fields in that table -- check the exact spellings. Also, check
> that TestType is a numeric field, and that the bound column of
> lstTestType contains numeric values.
>
> If I were writing this, I'd put a space into the SQL string before the
> "Values" keyword for clarity, but that isn't actually required in this
> case because the closing parenthesis is a sufficient delimiter.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      20th Mar 2006
"amy14775" <(E-Mail Removed)> wrote in message
news:FB553B8B-B9DC-4E92-B866-(E-Mail Removed)
> The names are all correct. But the TestType field is a text field
> with the name of the test needed in it. The same goes for the list
> boxes. Is this what is causing the problem?


I think so.

> If so do you know the
> direction I need to go to fix it.


Try this:

strSql = _
"Insert Into Test " & _
"(SocialSecurity,StartDate,TestType,DateDue) " & _
"Values ('" & _
Me.txtSocialSecurity & "', #" & _
Format(Me.txtStart, "mm/dd/yyyy") & "#, '" & _
Me.lstTestType & "', #" & _
Format(dteTest, "mm/dd/yyyy") & "#)"

That should work, provide the values for TestType can't contain the
single-quote character ('). I also took the liberty of forcing the
format of your date fields to mm/dd/yyyy, to prevent any chance of
misinterpretation of ambiguous dates.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      20th Mar 2006
OH GREAT GURU, I AM NOT WORTHY....It works great. Thank you so much. I could
not figure out for the life of me to figure out where I was missing it. Thank
you sooooooo much. I almost cried I was so happy.
Thank you

"Dirk Goldgar" wrote:

> "amy14775" <(E-Mail Removed)> wrote in message
> news:FB553B8B-B9DC-4E92-B866-(E-Mail Removed)
> > The names are all correct. But the TestType field is a text field
> > with the name of the test needed in it. The same goes for the list
> > boxes. Is this what is causing the problem?

>
> I think so.
>
> > If so do you know the
> > direction I need to go to fix it.

>
> Try this:
>
> strSql = _
> "Insert Into Test " & _
> "(SocialSecurity,StartDate,TestType,DateDue) " & _
> "Values ('" & _
> Me.txtSocialSecurity & "', #" & _
> Format(Me.txtStart, "mm/dd/yyyy") & "#, '" & _
> Me.lstTestType & "', #" & _
> Format(dteTest, "mm/dd/yyyy") & "#)"
>
> That should work, provide the values for TestType can't contain the
> single-quote character ('). I also took the liberty of forcing the
> format of your date fields to mm/dd/yyyy, to prevent any chance of
> misinterpretation of ambiguous dates.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      20th Mar 2006
"amy14775" <(E-Mail Removed)> wrote in message
news:C8C46B6F-B089-4383-A52F-(E-Mail Removed)
> OH GREAT GURU, I AM NOT WORTHY....


ROFL

> It works great. Thank you so much.


I'm glad I could help.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
execute batch file does not execute all command lines John Grandy Microsoft C# .NET 3 17th Dec 2009 02:01 AM
"Error trying to execute Frontpage (open as HTML Coul not execute. =?Utf-8?B?Um9k?= Microsoft Frontpage 0 1st Jul 2006 04:28 AM
can't execute SP NuB Microsoft ASP .NET 3 20th Jan 2006 09:51 PM
MSI to execute Tomi Microsoft Windows 2000 MSI 4 22nd Sep 2005 03:15 PM
qd.execute Lynn Microsoft Access VBA Modules 1 16th Sep 2004 01:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:20 AM.