ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 13th, 2006, 04:03 PM
eldin eldin is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 1 eldin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 32 sec
Reputation Power: 0
RESOLVED: Error 91 "object variable or with block variable not set" in VB6

I'm getting Runtime Error 91, "Object variable or With Block variable not set" on the following code:


Code:
Dim strSQL As String, strFundCode As String
Dim rstMove As ADODB.Recordset
Dim flgCostsAlreadyPresent As Boolean

'Check if there are already costs in destination year
'If this recordset is not empty then there are costs in destination year
With rstMove
    strSQL = "SELECT count(KeyNo) as cnt FROM tblITIPFunding " _
        & "WHERE KeyNo='" & ctlITIPRecord(Index).KeyNo & "' AND ProgramNo='" & strFund & "' AND Year>='" & Year & "';"
    .Open strSQL, cnn, adOpenStatic, adLockReadOnly, adCmdText  ''<----------error occurs on this line.
    .MoveFirst
    flgCostsAlreadyPresent = (!cnt > 0)
    .Close
End With


I'm writing this with VB 6. The intent of this block of code is to check whether records exist in our database which meet given criteria. The value stored in strSQL at the time the error occurs works correctly if executed in the database (MSAccess 2000).
In the line with the error, "cnn" refers to a global adodb.connection object, which is open and works fine elsewhere in the code. Can anyone give me some insight into what might be causing this problem?

Thanks,
Eldin

edit - The problem was resolved by changing the line:
Dim rstMove As ADODB.Recordset
to this:
Dim rstMove As New ADODB.Recordset

Last edited by eldin : January 13th, 2006 at 05:13 PM. Reason: RESOLVED

Reply With Quote
  #2  
Old December 19th, 2007, 06:31 PM
lazardev lazardev is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 1 lazardev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 59 sec
Reputation Power: 0
error 91

I got the same problem when using DAO. I solved it by adding DAO as a qualifier.

See DAO Programming Code Examples
' allenbrowne.com/func-DAO.html

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Error 91 "object variable or with block variable not set" in VB6


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap