-
I was creating a db program that use an MS Access database to hold the actual information. I started with MS Office 97pro & VB5, and everything was working fine. I picked up Office 2000 and installed it, and when I went to open the databse, it asked me if I wanted to upgrade it, I said sure, figuring it can't hurt (silly me). Now VB won't read the database, it keeps giving the error messege "Unrecognized database format". I thought that upgrading to VB6.0pro would fix it, but as I have done that already, and it still won't read the database. Any ideas on how to get VB to read Access 2000 databases? Thanx.
Thanx.
Rick Goodrow
-
If you're using DAO, make sure that you have version 3.6 selected (check under Project->References).
-
I tried that. I found "Microsoft DAO 3.6 Object Library" and checked it. VB required me to uncheck "Microsoft DAO 3.51 Object Library" but whenever I try to run it. I still get the same message. Any other ideas?
-
What code are you using to open the DB?
-
I'm not specifically using an open command. I just put a database object into the form, and linked it to the file. The first command I use with it is
'datinv.recordset.movelast'
to populate it.
Also, wnen I try to add a new database object and set the databasename to a Access 2000 database, I get the same error message, and can't even select a recordset.
-
That's your problem. Make sure you have the latest version of the DataControl. Although, it's a lot better to use code to open the DB.
-
Code is Key. Then the DAO 6.0 Library works, if you want code reply. I will give you some DAO Code to open the DB
-
If somebody can give me code for it, that'd be great, but I've never used code to open a database before, so I'll be new at it.
Also, the other problem is that when I place a data control on the form, then try to adjust the "DatabaseName" property to the Access 2000 file, I get the same error message, and it doesn't work. Could this be a problem with not having the latest Data Control?
P.S. This may be pushing it, but could somebody also provide a link to the latest Data Control please? (Haven't been on in awhile)
-
Sure, add the reference to the DAO 3.60, then:
Code:
Dim myDB As Database
Dim myRS As Recordset
Dim Records As Integer
Dim MyText() As String
Dim i as Integer
Set myDB = DBEngine.Workspaces(0).OpenDatebase("c:\My DB.mdb")
Set myRS = myDB.OpenRecordset("MyRS")
'put code here, i.e.
myRS.MoveLast
Records = myRS.RecordCount
ReDim MyText(Records)
myRS.MoveFirst
'to retrive data:
i = 1
Do Until myRS.EOF
i = i + 1
MyText(i).Text = myRS!Field
MyRS.MoveNext
Loop
myRS.Close
myDB.Close
Set myRS = Nothing
Set myDB = Nothing
Note: This is not tested, but it should work!!!
[Edited by gwdash on 09-18-2000 at 05:02 PM]
-
-
Oops, i edited something, you must close it all.
-
but you don't have to close it until the end, right?
-
Okay, I morphed that code into my program, and it uses the Access 2000 databases correctly now.
Except that another problem popped up. All of my .findfirst commands now say "operation is not supported for this type of object."
Now the question is how do I replace those commands with working commands that accomplish the same thing.
-
-
.movefirst works, but the .findfirst doesn't work, which is what I use to search for records.
-
To find records, use:
Code:
Set rst = DB.OpenRecordset("SELECT * FROM TheTable WHERE TheField=5")
rather than opening the table and using .FindFirst.
-
so if I have
BobDB as a database variable
CustomerRS as a recordset variable
and lets say I wanted to find "John" under the [First Name] field in the CustomerRS recordset.
What would the syntax be?
-
Sorry for the intrusion, I am trying to learn how to use databases with VB
and want to be alerted to the update to this thread.