Results 1 to 3 of 3

Thread: How to create a workspace in vb 6?

  1. #1

    Thread Starter
    Lively Member yahui's Avatar
    Join Date
    Jan 2001
    Posts
    102

    How to create a workspace in vb 6?

    Hi,

    What is a workspace? Can anyone teach me how to create a workspace in vb 6?

    The following is some codes that create workspace in vb 3. However when I load them in vb 6, it says
    "Can't start your application. The workgroup information is missing or opened exclusively by another user."

    Can somebody help me with this?

    Thank you very much.


    ************************************************************
    Private Sub cmdEnter_Click()
    Dim myAccess As dynaset
    Dim SQL As String

    If txtID.Text = "" Then
    MsgBox "Enter your ID"
    txtID.SetFocus
    Exit Sub
    End If

    If txtPassword.Text = "" Then
    MsgBox "Enter your Password"
    txtPassword.SetFocus
    Exit Sub
    End If

    ' to check id & password if correct??

    On Error GoTo err_hand

    SetDefaultWorkspace txtID.Text, txtPassword.Text

    usr_id = txtID.Text
    usr_password = txtPassword.Text

    Dim loctext
    loctext = LCase(App.Path)
    If Right(App.Path, 1) <> "\" Then loctext = loctext + "\" 'handles the root
    data_base = txt_path.Text
    Set tr_db = OpenDatabase(data_base)
    Set letter_set = tr_db.CreateDynaset("letter")

    AccessLevel = 0
    SQL = "Select AccessLevel from UserAccessLevel where LoginID = '" & usr_id & "'"
    Set myAccess = tr_db.CreateDynaset(SQL)
    If myAccess.RecordCount > 0 Then
    AccessLevel = myAccess("AccessLevel")
    Else
    AccessLevel = 1
    End If
    myAccess.Close

    db_path = txt_path.Text
    MainMenu.Show
    Unload Form1
    Exit Sub

    err_hand:
    MsgBox (Error)
    txtID.Text = ""
    txtPassword.Text = ""
    txtID.SetFocus
    Exit Sub
    End Sub


  2. #2
    Lively Member Kersey's Avatar
    Join Date
    Jun 1999
    Location
    The Netherlands
    Posts
    101

    Thumbs down Check your msdn for dao examples

    Code:
    Sub DatabaseObjectX()
    
       Dim wrkJet As Workspace
       Dim dbsNorthwind As Database
       Dim dbsNew As Database
       Dim dbsLoop As Database
       Dim prpLoop As Property
    
       Set wrkJet = CreateWorkspace("JetWorkspace", "admin", _
          "", dbUseJet)
    
       ' Make sure there isn't already a file with the name of
       ' the new database.
       If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"
    
       ' Create a new database with the specified
       ' collating order.
       Set dbsNew = wrkJet.CreateDatabase("NewDB.mdb", _
          dbLangGeneral)
       Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
    
       ' Enumerate the Databases collection.
       For Each dbsLoop In wrkJet.Databases
          With dbsLoop
             Debug.Print "Properties of " & .Name
             ' Enumerate the Properties collection of each
             ' Database object.
             For Each prpLoop In .Properties
                If prpLoop <> "" Then Debug.Print "  " & _
                   prpLoop.Name & " = " & prpLoop
             Next prpLoop
          End With
       Next dbsLoop
    
       dbsNew.Close
       dbsNorthwind.Close
       wrkJet.Close
    
    End Sub

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    The reference to the workgroup information file is the securtiy.mdb that Access uses to secure databases. You need to pass the location and name of that file in to the connection string when connecting to the database. It is listed as one of the extended properties. There are other threads on this in the Database forum. Try a search in there.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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