Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 3rd, 2004, 09:27 AM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
SQL Error

Good day,

I am getting an "Too few parameters error:Expected 1" on the indicated line below:

Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset

Dim strsql1 As String
Dim strsql2 As String
Dim strsql3 As String

Dim intExistV As Integer, intExistF As Integer, intTBAvail As Integer, dblForeAb As Double, intTrueAvail As Integer, dblThresh As Double

Set db = CurrentDb()

strsql1 = "Select Count([empid]) as CountofEmpID from tblvacation where [tblvacation]![curtour] = " & Me.curtour
strsql2 = "Select count([empid]) as CountofTourEmps from tblEmployee where tblEmployee.curtour = " & Me.curtour
strsql3 = "Select Count([empid]) as CountofEmpIDF from tblfloater where tblfloater.curtour = " & Me.curtour


Set rs1 = db.OpenRecordset(strsql1) <--Error on this line
Set rs2 = db.OpenRecordset(strsql2)
Set rs3 = db.OpenRecordset(strsql3)

Just wondering if anyone my know what is causing this?
I know the syntax is correct and the remaining parameters are optional.

Thanks

Reply With Quote
  #2  
Old February 3rd, 2004, 09:55 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
Syntax incorrect-- can't use "!" here, use "."

strsql1 = "Select Count([empid]) as CountofEmpID from tblvacation where [tblvacation].[curtour] = " & Me.curtour

Only other possible problem is that you have either your table name or field name spelled wrong.

S-

Reply With Quote
  #3  
Old February 3rd, 2004, 10:06 AM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
Thanks for the reply S. But still getting the error. I have double checked the table/field names and they are correct.

Let me know if you have any other suggustions!

Reply With Quote
  #4  
Old February 3rd, 2004, 10:12 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
Are you sure that

[tblvacation].[curtour]

is a numeric field and not text

S-

Reply With Quote
  #5  
Old February 3rd, 2004, 10:13 AM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
It is a text field.
Would I have to make any changes to the code?

Help

Last edited by canadian : February 3rd, 2004 at 10:20 AM.

Reply With Quote
  #6  
Old February 3rd, 2004, 10:38 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
text variables need ' around it

strsql1 = "Select Count([empid]) as CountofEmpID from tblvacation where [tblvacation].[curtour] = '" & Me.curtour & "'"


S-

Reply With Quote
  #7  
Old February 6th, 2004, 10:01 AM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
Hey Again,

I want to make an addition to the statement:

strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "'"

Basically it will be a where cause like this

Where tblvaction.vdate = Me.vdate

Do anyone know if it is possible to add that to the statement above.

Thanks

Last edited by canadian : February 6th, 2004 at 10:07 AM.

Reply With Quote
  #8  
Old February 6th, 2004, 10:25 AM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "' and tblvaction.vdate = #" & Me.vdate & "#;"


S-

Reply With Quote
  #9  
Old February 6th, 2004, 11:12 AM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
Hey I hate to trouble again,

But I am getting the error
"Too few parameters error:Expected 1"

It is showing up on the indicated error line:

Dim db As Database
Dim rs1 As Recordset
Dim rs2 As Recordset
Dim rs3 As Recordset

Dim strsql1 As String
Dim strsql2 As String
Dim strsql3 As String

Dim intExistV As Integer, intExistF As Integer, intTBAvail As Integer, dblForeAb As Double, intTrueAvail As Integer, dblThresh As Double
Dim RetVal As String

Set db = CurrentDb()

strsql1 = "Select Count([empid]) as Countofempid from tblvacation where tblvacation.curtour = '" & Me.curtour & "' and tblvaction.vdate = #" & Me.txtvdate & "#;"
strsql2 = "Select count([empid]) as CountofTourEmps from tblEmployee where tblEmployee.curtour = '" & Me.curtour & "'"
strsql3 = "Select Count([empid]) as CountofEmpIDF from tblfloater where tblfloater.curtour = '" & Me.curtour & "'"


Set rs1 = db.OpenRecordset(strsql1) <---Error is here
Set rs2 = db.OpenRecordset(strsql2)
Set rs3 = db.OpenRecordset(strsql3)
rs1.MoveFirst
intExistV = rs1![CountofEmpID]
rs2.MoveFirst
intTBAvail = rs2![CountofTourEmps]
rs3.MoveFirst
intExistF = rs3![CountofEmpIDF]
rs1.Close
rs2.Close
rs3.Close

dblForeAb = intTBAvail * 0.1
intTrueAvail = intTBAvail - dblForeAb
dblThresh = intTrueAvail * 0.04

Note: In my previous post I indicated Me.vdate but the correct name of the textbox is txtvdate.
Also the field txtvdate is Unbound.

Thanks Again

Last edited by canadian : February 6th, 2004 at 11:34 AM.

Reply With Quote
  #10  
Old February 6th, 2004, 12:43 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
I guess I should have asked before

tblvaction.vdate is a date field, right?

S-

Reply With Quote
  #11  
Old February 6th, 2004, 12:48 PM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
sure is.

Reply With Quote
  #12  
Old February 6th, 2004, 12:51 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
In you SQL statement tblvacation is spelled wrong

S-

Reply With Quote
  #13  
Old February 6th, 2004, 12:59 PM
canadian canadian is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 70 canadian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 13 m 7 sec
Reputation Power: 5
Crazy! I have been here for looking @ the dam statement for an hour. Working Now. Thanks.
Do it still matter that txtvdate is a date field?

Reply With Quote
  #14  
Old February 6th, 2004, 01:59 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
I assumed it was a date because I had you put #aroundit#

strings need '
dates need #

S-

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > SQL Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |