|
-
May 31st, 2000, 12:43 AM
#1
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?
-
May 31st, 2000, 12:51 AM
#2
New Member
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
-
May 31st, 2000, 01:04 AM
#3
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]
-
May 31st, 2000, 06:53 AM
#4
New Member
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
-
May 31st, 2000, 08:15 AM
#5
PowerPoster
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
-
May 31st, 2000, 06:06 PM
#6
yeah ...
thanks chris.. and all of u guys..
finally got it working..
just curios.. wat does the "DAO" means??
-
Jun 1st, 2000, 06:56 AM
#7
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|