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
ASP

Avatar of undefined
Last Comment
gmoney4

8/22/2022 - Mon
Scott Fell

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

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...
Scott Fell

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
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
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
Scott Fell

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'")
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
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
Scott Fell

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?
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
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Scott Fell

gmoney4

ASKER
that worked!!

now question is, how do i display the first day of the month, in the current month??
Scott Fell

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&"#")

%>
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
gmoney4

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