stupid access.....?? (1 Viewer)

dgoulston

Hasn't Got A Clue
Local time
Today, 23:18
Joined
Jun 10, 2002
Messages
403
ok here is my code, when it gets to the Set ws = DBEngine.Workspaces(0) line it says

"could not use c:\db.mdb, file allready open"

but of course its open,,, its the database this code is being run from, but i never had this come up before, and even if i comment out that line i get the same error for the next line Set db = CurrentDb()

any ideas?

Code:
    Dim tablename As String
    Dim db As Database
    Dim tdf As TableDef
    Set ws = DBEngine.Workspaces(0)
    Set db = CurrentDb()
    Set tdf = db.CreateTableDef("DNRACS")
    Dim tmpnum As Integer
    Dim tmplabel()
    tmplabel = Array(lblchk1, lblchk2, lblchk3, lblchk4, lblchk5)
    'sourcedb = openfiledb("c:\") 'open file diolog
    tablename = tmplabel(chkval - 1).Caption 'gets table name from a text box
    tdf.Connect = ";DATABASE=" & sourcedb
    tdf.SourceTableName = tablename
    db.TableDefs.Append tdf[list]

thanks
DAL
 

AlanS

Registered User.
Local time
Today, 18:18
Joined
Mar 23, 2001
Messages
292
When I copy and paste your code into a sub and run it, I get an error message stating that the variable ws is not defined.; When I put in a Dim statement to define it as a workspace variable, the code runs OK until this statement:

tmplabel = Array(lblchk1, lblchk2, lblchk3, lblchk4, lblchk5)

where I get the same error regarding lblchk1. I'm not sure why you're getting different error messages, but the first thing I would do is make sure all variables are properly Dimmed.
 

dgoulston

Hasn't Got A Clue
Local time
Today, 23:18
Joined
Jun 10, 2002
Messages
403
no luck

its still not working!!!!! argh!!!!!!

ive added the
Code:
dim ws as workspace
line and still the same error. if i comment out the set ws line then it jus brings the error up on the next line!!! arghhhhhhhhhhhh

thanks
DAL
 
Last edited:
R

Rich

Guest
Dim CurDB As DATABASE,
Set CurDB = DBEngine.Workspaces(0).Databases(0)
works in 97, you may have to use
Dim CurDB As DAO DATABASE,
 

Users who are viewing this thread

Top Bottom