Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2007, 06:48 PM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Vb6 access 97 recordset problem

I am running a search on my database and evrything works, but when I try to view the next record I get a message Variable not set.
I am running Vb6 with access 97. I put the part of code that is giving me trouble in bold.....please help.

Code:
Option Explicit
Dim SQL As String

Private oDatabase As ADODB.Connection 'this is the connection
Private oRS As ADODB.Recordset 'this is the recordset


Private Sub cmdSearch_Click()

Dim sSearchText As String
Dim Clientname As String
Dim oDatabase As ADODB.Connection: Set oDatabase = New ADODB.Connection
Dim oRS As ADODB.Recordset: Set oRS = New ADODB.Recordset

    List1.Clear
    List2.Clear

         sSearchText = txtSearch
         lblSearch.Visible = True
         MousePointer = vbHourglass

    With oDatabase

        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "Data Source=" & App.Path & "\KJV.mdb"
        .Open

    End With

        Set oRS = New ADODB.Recordset 

       oRS.Open "BibleTable", oDatabase, adOpenKeyset, adLockPessimistic, adCmdTable 'opening the recordset 
    oRS.Filter = "[TextData] LIKE '%" & sSearchText & "%'"
   oRS.Open "SELECT * from BibleTable WHERE [TextData] LIKE '%" & sSearchText & "%'", oDatabase, adOpenForwardOnly, adLockReadOnly

      If oRS.EOF Then
      MsgBox "No record found matching "

      Else
          oRS.MoveFirst


 End If

      List1.Clear
      List2.Clear

Do Until oRS.EOF

      List1.AddItem (oRS.Fields(4))
      List2.AddItem (oRS.Fields(1))
      oRS.MoveNext

Loop
      If Not (oRS.BOF = True) Then
      oRS.MoveFirst
      If oRS.BOF = True Then

      MsgBox "Records Found"
      Else
           txtBookTitle = oRS.Fields("BookTitle")
                txtChapter = oRS.Fields("Chapter")
                   txtVerse = oRS.Fields("Verse")
                     txtData = oRS.Fields("TextData")
End If

      List1.Visible = True
      List2.Visible = True
      cmdReset.Visible = True
End If


End Sub

Private Sub cmdNext_Click()

If Not (oRS.EOF = True) Then 
oRS.MoveNext
If oRS.BOF = True Then
MsgBox "You are at the first Verse", vbExclamation, "Holy Bible KJV"
Exit Sub
Else
txtBookTitle = oRS.Fields("BookTitle")
txtChapter = oRS.Fields("Chapter")
txtVerse = oRS.Fields("Verse")
txtData = oRS.Fields("TextData")

End If
End Sub
 
Old July 28th, 2007, 12:57 PM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I solved this myself.......thanks.

 
Old July 28th, 2007, 02:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

please if you solved it post the solution..

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old August 1st, 2007, 06:12 PM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gbianchi
 please if you solved it post the solution..

HTH

Gonzalo
Code:
oRS.Open "SELECT * from BibleTable WHERE [TextData] LIKE '%" & sSearchText & "%'", oDatabase, adOpenStatic, adLockReadOnly
the changes were made in this part of the code. Hope this helps someone else.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with memo field in Access 97 Ardeshir Access 4 December 27th, 2004 06:05 AM
Access 97 Date format problem Andrew Antoniak Access VBA 2 February 21st, 2004 12:47 PM
Access 97 Benwaa Access VBA 0 January 28th, 2004 02:37 PM
Migrating from access 97 to access 2000 Khalifeh Access 12 October 2nd, 2003 02:54 PM
Listboxes In Access 97 timmaher Access VBA 6 June 9th, 2003 03:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.