Help needed with SQL (runtime Error 91) 
Author Message
 Help needed with SQL (runtime Error 91)

Hi,

I have a piece of code - in Access 97 - that goes and queries some tables
for documents edited by someone...it works but when I try to change the SQL
so that it will find documents edited between 2 dates, I get runtime error
91
(Object variable or With block variable not set). My help file is in
Japanese and I'm not able to follow it. Any help would be great. (Code is
below)

Thanks in advance,
John

The code that works
-----------------
sSQL = "SELECT Documents.ID, Title, Description, DocEditHist.Document FROM
DocEditHist INNER JOIN Documents ON DocEditHist.Document = Documents.ID
WHERE DocEditHist.EditedBy=" & Me!SelectItList.Column(2) & " ORDER BY
Title;"

Set qdQuery = dbThisDB.CreateQueryDef("qryWhat", sSQL)
Set rsThisRS = qdQuery.OpenRecordset(dbOpenSnapshot, dbReadOnly)

The changed SQL that causes the problem
------------------------------------
sSQL = "SELECT Documents.ID, Title, Documents.Description,
DocEditHist.Document FROM DocEditHist INNER JOIN Documents ON
DocEditHist.Document = Documents.ID WHERE DocEditHist.EditDate>=" & X & "
AND DocEditHist.EditDate<=" & Y & "  ORDER BY Title;"



Sun, 12 May 2002 03:00:00 GMT  
 Help needed with SQL (runtime Error 91)
Try setting your database variable. If your table is in the same database, it
would be like this:

     Set dbThisDb = CurrentDb

Good Luck

Mark

Quote:

> Hi,

> I have a piece of code - in Access 97 - that goes and queries some tables
> for documents edited by someone...it works but when I try to change the SQL
> so that it will find documents edited between 2 dates, I get runtime error
> 91
> (Object variable or With block variable not set). My help file is in
> Japanese and I'm not able to follow it. Any help would be great. (Code is
> below)

> Thanks in advance,
> John

> The code that works
> -----------------
> sSQL = "SELECT Documents.ID, Title, Description, DocEditHist.Document FROM
> DocEditHist INNER JOIN Documents ON DocEditHist.Document = Documents.ID
> WHERE DocEditHist.EditedBy=" & Me!SelectItList.Column(2) & " ORDER BY
> Title;"

> Set qdQuery = dbThisDB.CreateQueryDef("qryWhat", sSQL)
> Set rsThisRS = qdQuery.OpenRecordset(dbOpenSnapshot, dbReadOnly)

> The changed SQL that causes the problem
> ------------------------------------
> sSQL = "SELECT Documents.ID, Title, Documents.Description,
> DocEditHist.Document FROM DocEditHist INNER JOIN Documents ON
> DocEditHist.Document = Documents.ID WHERE DocEditHist.EditDate>=" & X & "
> AND DocEditHist.EditDate<=" & Y & "  ORDER BY Title;"



Sun, 12 May 2002 03:00:00 GMT  
 Help needed with SQL (runtime Error 91)
Hi Mark,

Thanks...and sorry it was something so simple. I have been
away from Access too long!

John

Quote:

>Try setting your database variable. If your table is in the same database,
it
>would be like this:

>     Set dbThisDb = CurrentDb

>Good Luck

>Mark


>> Hi,

>> I have a piece of code - in Access 97 - that goes and queries some tables
>> for documents edited by someone...it works but when I try to change the
SQL
>> so that it will find documents edited between 2 dates, I get runtime
error
>> 91
>> (Object variable or With block variable not set). My help file is in
>> Japanese and I'm not able to follow it. Any help would be great. (Code is
>> below)

>> Thanks in advance,
>> John

>> The code that works
>> -----------------
>> sSQL = "SELECT Documents.ID, Title, Description, DocEditHist.Document
FROM
>> DocEditHist INNER JOIN Documents ON DocEditHist.Document = Documents.ID
>> WHERE DocEditHist.EditedBy=" & Me!SelectItList.Column(2) & " ORDER BY
>> Title;"

>> Set qdQuery = dbThisDB.CreateQueryDef("qryWhat", sSQL)
>> Set rsThisRS = qdQuery.OpenRecordset(dbOpenSnapshot, dbReadOnly)

>> The changed SQL that causes the problem
>> ------------------------------------
>> sSQL = "SELECT Documents.ID, Title, Documents.Description,
>> DocEditHist.Document FROM DocEditHist INNER JOIN Documents ON
>> DocEditHist.Document = Documents.ID WHERE DocEditHist.EditDate>=" & X & "
>> AND DocEditHist.EditDate<=" & Y & "  ORDER BY Title;"



Mon, 13 May 2002 03:00:00 GMT  
 Help needed with SQL (runtime Error 91)


Quote:
>sSQL="SELECT Documents.ID, Title, Documents.Description," & _
>    "  DocEditHist.Document" & _
>    "FROM DocEditHist INNER JOIN Documents " & _
>    "  ON DocEditHist.Document = Documents.ID " & _
>    "WHERE DocEditHist.EditDate>=" & X & _
>    "  AND DocEditHist.EditDate<=" & Y & _
>    "ORDER BY Title;"

You don't say quite what X and Y are, but is it safe to assume that
they are data values formatted with something like:

  Format$(SomeDate, "\#yyyy\-mm\-dd\#")

Just thought I'd check...  :-)

Tim F

--



Mon, 13 May 2002 03:00:00 GMT  
 Help needed with SQL (runtime Error 91)
Hi Tim,

Yes X and Y are dates. Mark's equally basic pointer solved
the problem. Thanks for checking though!

John



Tue, 14 May 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB5 Ent - Wierd runtime 91 error - NEED HELP

2. runtime error 91 sql/access

3. HELP : Error 91 : Run-Time Error 91 Object Variable or With

4. Error 91 - Object Variable Not Set **** Need Help

5. Runtime error 91

6. Runtime Error #91

7. RUNTIME ERROR 91 OPENING WORD

8. RUNTIME ERROR 91 OPENING WORD

9. runtime error 91

10. encounter runtime error 91

11. Runtime Error 91

12. Runtime Error 91 on Mydata.UpdateRecord (long post)

 

 
Powered by phpBB® Forum Software