Link to home
Start Free TrialLog in
Avatar of gmoney4
gmoney4

asked on

ADODB.Field error '800a0bcd' Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

Hi all and thanks in advance, I am complete stumped as to why this isnt working...

error:
ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/kpis.asp, line 112

code:
MonthBegin=DateSerial(Year(Now),Month(Now),1)
                                    
Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month="&MonthBegin&" AND user_ID="&Session("ID"))

OldProj=UserTargets("user_proj") <---- Line 112
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

One option is to test if there is data

<%

if not UserTargets.bof or not  UserTargets.eof then ' run the group of code needed below

         OldProj=UserTargets("user_proj") <---- Line 112

         :
         :
         :
         :
else
      response.write ("no data")
end if
%>

Open in new window

Avatar of gmoney4
gmoney4

ASKER

thanks for that, the output is showing 'no data', but the database clearly has the corresponding data for it...

MonthBegin shows 1/07/12 (which is exactly in the database) and SessionID is 6, which is also in the database...
It must not be that clear.  The reason for the error your  query of the dbf is not bringing up any data.

To troubleshoot, start by replacing
Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month="&MonthBegin&" AND user_ID="&Session("ID"))

with

Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month="&7&" AND user_ID="&6

The possible problem is your "MonthBegin" looks like a date (1/07/12) and not a month.  If it is a date, shouldn't it be 1/7/2012.   And then to get the month in your sql you will use datepart http://msdn.microsoft.com/en-us/library/ms174420.aspx
Avatar of gmoney4

ASKER

in my database, the value is 1/07/2012 the same as MonthBegin, should that matter?? target_month is the just the title of the column
Avatar of gmoney4

ASKER

Microsoft VBScript compilation error '800a03ee'

Expected ')'

/kpis.asp, line 109

Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month="&7&" AND user_ID="&6&"")

errored at the 7, prob cause it has "& &" around it...

removing the "& &" and just leaving the numbers as you said, it does the same error as original
Is the target_month / MonthBegin supposed to be a date or a month?  If it is supposed to be a date, then  use  

Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month='1/07/2012'")
Avatar of gmoney4

ASKER

it suppose to be a date, here is the error i get:

Microsoft JET Database Engine error '80040e07'

Data type mismatch in criteria expression.

/kpis.asp, line 109

109 being the the Set UserTargets Line
It has been a long time since I used access. But I think the problem is the date needs to be in hashtags and not single quotes.  I gave you what I use for sql server.


Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month=#1/07/2012#")

Are you sure the date is formated as 1/07/2012?    Should it be 1/7/2012?  Is this for jan 7 or July 1?
Avatar of gmoney4

ASKER

MonthBegin displays as 1/072012, as well as it shows exact same in the Access DB.

it is 1JULY to be that precise date.

with hash tags, here is the error im getting:

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/kpis.asp, line 112

112 pointing towards the OldProj=UserTargets("user_proj") Line
access-target-month.jpg
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gmoney4

ASKER

that worked!!

now question is, how do i display the first day of the month, in the current month??
That really is beyond the scope of this question.  In vbscript the current date is simply <%=date%>.   To get the current month <%=month(date)%>   If you need to come up with July 1, 2012 or 7/1/2012 you could use  <%=month(date)&"/1/"&year(date)%>  Your sql might look like


<%
theDate=month(date)&"/1/"&year(date)  ' 7/1/2012

Set UserTargets=oConn.Execute("SELECT * FROM user_targets WHERE target_month=#"&theDate&"#")

%>
Avatar of gmoney4

ASKER

cheers for that it is all making sense now!! :)