Any help for my problem is highly appreciated:
after searching the net for a day I have yet to connect the dots as how to use the CopyObjects method to update some forms in a secured database of which I am the administrator. The thing is, I am at home and some clients are using my database on a different location. I thought it should be possible to create an almost empty MDB with in it some changed forms/reports etc. and use code from this "update database" to copy all those to their local version. I don't feel like providing them with my admin password so they can log on with design privileges, nor do I want to visit them all the time (there's quite a distance between us).
I am trying in a sample MDB to enable both the opening of a secured DB and the copying of those forms, but am so far unsuccesful (took me a while to realise that the DBEngine.systemDB property can only be set upon starting of the db BEFORE any ADO instructions are run...). I'm confused as when to use workspaces, is there anyone that can be of any assistance? Thanx in advance, my meddling in code so far has led to
which doesn't work because no matter how I try, the DBEngine.SystemDB stays at default...
Thanx to some further browsing on the net, I managed to open the secure DB by using
but this naturally doesn't work because CopyObject doesn't recognize the "TestIt2" target.
I'm baffled! Please help..
after searching the net for a day I have yet to connect the dots as how to use the CopyObjects method to update some forms in a secured database of which I am the administrator. The thing is, I am at home and some clients are using my database on a different location. I thought it should be possible to create an almost empty MDB with in it some changed forms/reports etc. and use code from this "update database" to copy all those to their local version. I don't feel like providing them with my admin password so they can log on with design privileges, nor do I want to visit them all the time (there's quite a distance between us).
I am trying in a sample MDB to enable both the opening of a secured DB and the copying of those forms, but am so far unsuccesful (took me a while to realise that the DBEngine.systemDB property can only be set upon starting of the db BEFORE any ADO instructions are run...). I'm confused as when to use workspaces, is there anyone that can be of any assistance? Thanx in advance, my meddling in code so far has led to
Code:
Private Function TestIt()
DBEngine.SystemDB = "E:\TestBeveil.mdw"
Dim ExportDbs As String
Dim db As Database
Dim sUserName As String
Dim sPassword As String
Dim ws As Workspace
sUserName = "UsName"
sPassword = "PssWd"
ExportDbs = "E:\db2.mdb"
'Export Forms
MsgBox DBEngine.SystemDB 'to check if DBEngine.SystemDB is updated
Set ws = DBEngine.CreateWorkspace("Temp", sUserName, sPassword)
Set db = ws.OpenDatabase("Temp")
DoCmd.CopyObject ExportDbs, "Form1", acForm, "Form1"
db.Close
ws.Close
End Function
which doesn't work because no matter how I try, the DBEngine.SystemDB stays at default...
Thanx to some further browsing on the net, I managed to open the secure DB by using
Code:
Public Function TestIt2() As DAO.Database
Dim MyDBEngine As New DAO.DBEngine
Dim ExportDbs As String
MyDBEngine.SystemDB = "E:\TestBeveil.mdw"
MyDBEngine.DefaultUser = "UsName"
MyDBEngine.DefaultPassword = "PssWd"
ExportDbs = "E:\db2.mdb"
'Open the specified database in the new DBEngine and return pointer to function
MsgBox MyDBEngine.SystemDB 'to check if MyDBEngine.SystemDB is updated
Set TestIt2 = MyDBEngine.OpenDatabase(ExportDbs)
DoCmd.CopyObject TestIt2, "Form1", acForm, "Form1"
'Close object variables and set to nothing to release system resources
Set MyDBEngine = Nothing
End Function
but this naturally doesn't work because CopyObject doesn't recognize the "TestIt2" target.
I'm baffled! Please help..