Results 1 to 7 of 7

Thread: database problem

  1. #1
    Guest
    I have problems accessing my database. this is wat happens.

    the code below is a part of my program.

    Private Sub log()
    Dim foundflag As Boolean
    datavalues = Left$(strData, len (strdata, - 2)
    If Len(datavalues) > 0 Then
    data1.Recordset.MoveFirst <--- Problems Here!!!
    foundflag = False

    ....... bla-bla-bla


    it gives me an error of "Object Variable or With Block variable not set"

    wat does this mean?

  2. #2
    New Member
    Join Date
    May 2000
    Posts
    13
    I don't know where data1 comes from, so I'll ask:

    1. Have you opened your database already?
    2. Have you opened your recordset already?

    I have been using this with success, don't know if it fits your application...

    -----------------------
    Dim myDB As Database
    Dim recs As Recordset

    Set myDB = OpenDatabase(App.path & "\Machines.mdb")
    Set recs = myDB.OpenRecordset("Departments", dbOpenSnapshot)
    While Not recs.EOF
    txtLegend.Text = txtLegend.Text & (recs!Description) & vbCrLf
    recs.MoveNext
    Wend
    recs.Close
    Set recs = Nothing
    myDB.Close
    Set myDB = Nothing
    -----------------------

    This, as an example, opens a database, opens a recordset and then puts the description of each item in the database onto different lines of a text control. The recordset and database are then closed.

    Shawn

  3. #3
    Guest

    Unhappy a ha....

    ok ok.. i've tried the codes.. it should work but it gave me a problem saying "Type Mismatched" on this line...
    I've already set 'records' as Recordset.

    ---> Set records = UserData.OpenRecordset("user", dbOpenSnapShot) <-----

    [Edited by KenC.J on 05-31-2000 at 02:18 PM]

  4. #4
    New Member
    Join Date
    May 2000
    Posts
    13

    Talking Need more info...

    Maybe someone else could help, but I need more info to try and help, post more code if you can. Are you sure the database contains that table?

    Shawn

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb Set the Data object recordset first

    Hi KenC.J you need to set the recordset for the Data1 object before you can really move the recordset to next record.

    Code:
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim foundflag As Boolean 
    
    Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\123.mdb", False, False)
    Set rs = db.OpenRecordset("Tbl456", dbOpenSnapshot)
    
    Set Data1.Recordset = rs
    
    'Bla...bla...bla.....
    
    datavalues = Left$(strData, len (strdata, - 2) 
    If Len(datavalues) > 0 Then 
    Data1.Recordset.MoveFirst
    foundflag = False

  6. #6
    Guest

    Cool yeah ...

    thanks chris.. and all of u guys..

    finally got it working..


    just curios.. wat does the "DAO" means??

  7. #7
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb

    DAO = Data Access Object
    ADO = ActiveX Data Object

    [Edited by Chris on 06-02-2000 at 04:32 AM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width