Solved

workspace creation in access 2010

Posted on 2013-01-12
3
511 Views
Last Modified: 2013-01-12
Hi,
I put this in a form in access :

Workspace.CreateDatabase(ByVal Name As String, _
                   ByVal locale As String, _
                   ByVal options As Variant) As Database


Private Sub cmdDatabase_Click()
    DBEngine.Workspaces(0).CreateDatabase("Exercise.accdb", . . .)
End Sub


not working when i click on the button in the access form ..
may any help  :}
0
Comment
Question by:drtopserv
  • 2
3 Comments
 
LVL 39

Expert Comment

by:als315
ID: 38770261
Try to use this code:
Private Sub cmdDatabase_Click()
    Dim dbs as DAO.Database
    Set dbs = DBEngine.Workspaces(0).CreateDatabase("Exercise.accdb", dbLangGeneral)
    dbs.close
End Sub

Open in new window

0
 

Author Comment

by:drtopserv
ID: 38771196
Yea i know that through DAO i can create the db.
but i`m asking why through the code i paste above can`t able to run it ..
it is just to learning purpose.
0
 
LVL 39

Accepted Solution

by:
als315 earned 200 total points
ID: 38771240
DBEngine.Workspaces(0).CreateDatabase("Exercise.accdb", . . .) should return value to object, so proper syntax is:
Set ObjectVariable = DBEngine.Workspaces(0).CreateDatabase("Exercise.accdb", . . .)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now