473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Object Variable or with block not set

Hi Guys

Thanks for the replies. I started a thread but my network was down and I can't find my thread. Am using VB6.0 and developing a result checker.

I want to search records from an Access database using four fields from the database.

This is the code I have but I have this error
Object Variable or with block not set and the line of code is this objobjRs.open Sqlstmt objConn, ,2,2

Expand|Select|Wrap|Line Numbers
  1. sqlStmt = "select * from candres where ExamSeries='" & Exam_Sr & "' and  ExamYear= '" & Exam_Yr & "' and CentNo='" & cbosch & "' and IndexNo='" & Cand_No & "'"
  2. objobjRS.Open sqlStmt, objConn, , 2, 2
  3.  
  4. If Not (objobjRS.EOF) Then
  5.   frmCandResult.Show vbModal, Me
  6. Else
  7.   MsgBox "sorry not a perfect match"
  8. End If
Where am I going wrong?

Thanks
Oct 11 '07 #1
4 2333
Killer42
8,435 Expert 8TB
How is objobjRS declared?
Oct 11 '07 #2
How is objobjRS declared?

objobjRs is declared as Recordset and the declaration is made in the General section of the code section.

Thanks
Oct 16 '07 #3
QVeen72
1,445 Expert 1GB
hI,

How you have declared it..? have you used "New" keyword..?

Dim objRS As New ADODB.RecordSet

How about objConn, is it opened..?

Regards
Veena
Oct 16 '07 #4
hI,

How you have declared it..? have you used "New" keyword..?

Dim objRS As New ADODB.RecordSet

How about objConn, is it opened..?

Regards
Veena

Thanks QVeen

I have declared everything and this how I did it.

Expand|Select|Wrap|Line Numbers
  1. Dim objConn As ADODB.Connection
  2. Dim objobjRS As ADODB.Recordset
  3. ' The above declaration is in the General section
  4.  
  5. Sub frmCand_Details()
  6.  
  7. Set objConn = New ADODB.Connection
  8. Set objobjRS = New ADODB.Recordset
  9.  
  10. objConn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=c:\resultchecker.mdb")
  11. objobjRS.ActiveConnection = objConn.DefaultDatabase
  12.  
  13. End Sub
This is where i call the connection code to search the database

Expand|Select|Wrap|Line Numbers
  1. sqlStmt = "select * from candres "
  2. objobjRS.Open sqlStmt, objConn, , 2, 2
  3. flg = 0
  4. If Not (objobjRS.EOF) Then
  5.   Do Until objobjRS.EOF
  6.     If (objobjRS.ExamSeries = Exam_Sr And objobjRS.ExamYear = Exam_Yr And objobjRS.cbosch = Cent_No And objobjRS.IndexNo = Cand_No) Then
  7.       flg = 1
  8.       frmCandResult.Show vbModal, Me
  9.     End If
  10.     objobjRS.MoveNext
  11.   Loop
  12.   If (flg = 0) Then
  13.     MsgBox "sorry no records matched your requirements"
  14.   End If
Pls help because I can't just figure out the problem.

Thanks a lot.
Oct 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Hung Jung Lu | last post by:
Hi, Does anybody know where this term comes from? "First-class object" means "something passable as an argument in a function call", but I fail to see the connection with "object class" or...
10
by: Michael McCracken | last post by:
Hi, I have a problem with unittest.TestCase that I could really use some help with. I have a class File in module File. The important thing about File for this discussion is that it's simple -...
6
by: Neo Geshel | last post by:
I am trying to deal with an image in code-behind. I consistently get the following error: Server Error in '/' Application. Object variable or With block variable not set. Description: An...
6
by: Neo Geshel | last post by:
I am trying to deal with an image in code-behind. I consistently get the following error: Server Error in '/' Application. Object variable or With block variable not set. Description: An...
3
by: Newbie19 | last post by:
I'm trying to get a list of all subfolders in a folder on a share drive, but I keep on getting this error message: Object variable or With block variable not set. Description: An unhandled...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.