Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Module freezes when run under Windows 2000 2

Status
Not open for further replies.

infdarsas

Technical User
Jul 14, 2005
15
US
Hi,

I have the following module run when the form loads. It works fine under Windows XP, but under Windows 2000, the form freezes and just stays there. It is supposed to close, but it doesn't.

Here's the code from the module:

Code:
Option Compare Database
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long



Function OpenPasswordProtectedDB() As Boolean
Static acc As Access.Application
Dim Lox As Long

Lox = apiShowWindow(hWndAccessApp, 2)

Set acc = New Access.Application
    acc.Visible = True
    acc.OpenCurrentDatabase CurrentProject.Path & "\" & "Database.mdb", , "Password"
    OpenPasswordProtectedDB = True

End Function

What could be messing it up?


Thanks
 
In Win2000, I tried your code and got an error (wrong number of arguments or invalid property assignment) when compiling on the line:
acc.OpenCurrentDatabase ....
Checked help file for OpenCurrentDatabase and see PASSWORD is not an option.
Then opened XP version and see PASSWORD is acceptable.

Does this help?

"Hmmm, it worked when I tested it....
 
Hi Trevil,

Yes, that helped quite a bit. How would I protect my main database if the password is removed? I do not want to make it an .mde file because for some reason, the machine that is running Windows 2000 has issues when running .mde files. Any suggestions?

Thanks
 
We're running Win-2K and Office 2K and have never had any problems with mde's, but then again there are limitations/restrictions that may fall within your "2000 hase issues ... mde files".

It may help if I understood what you're trying to do and why. It appears that you have DB1 trying to open DB2 which is pwd protected? Then I assume there is some way a user can work inside your DB2?

There are lots of options regarding protection (code, objects, permissions, etc.), so it would help to know what you're trying to protect.

I hate to tell you, but a database password only keeps out the first level user.

"Hmmm, it worked when I tested it....
 
Yes, that is what I had going. I had one database open the main database (with tables, forms, etc.), which was password-protected. The main database lets user input data and so forth. What I am trying to do is to protect the main database so that the user cannot access the forms' designs and also the actual code for the entire program.

Basically, I do not want the user to have the ability to glance at the inner-workings of the program (forms, queries, modules, etc.) What would be your suggestion for this case?


Thanks
 

As I ramble on...
1. The easiest way to protect code and form design is to create an MDE. If you say you have problems with an MDE, then maybe we could solve those.

2. You can hide code by going to the VBA window, Tools | xxx Properties | Click Protection tab and set password.

3. You can hide the database window and set other options by running code (something like the following; NOTE 'ChangeProperty' is a user written subroutine)):
ChangeProperty "StartupForm", DB_Text, "frmMainMenu"
ChangeProperty "StartupShowDBWindow", DB_BOOLEAN, False
ChangeProperty "StartupShowStatusBar", DB_BOOLEAN, False
ChangeProperty "AllowBuiltinToolbars", DB_BOOLEAN, False
ChangeProperty "AllowFullMenus", DB_BOOLEAN, False
ChangeProperty "AllowBreakIntoCode", DB_BOOLEAN, False
ChangeProperty "AllowSpecialKeys", DB_BOOLEAN, False
ChangeProperty "AllowBypassKey", DB_BOOLEAN, False

But the above is also only good enough to foil students in grades 1-5.

4. If you want to get more serious, you can create a different 'Workgroup Admin file', then set permissions for all your database objects, then force your database to only be used via that file (you can search for info on this method in Tek-Tips).

Hope something here helps.


"Hmmm, it worked when I tested it....
 
Thanks for the tips. As it stands right now, the people that I have using the program do not have a very knowledgeable computer background. Something like #3 that you described above will surely do the trick for them. I am just wondering if I could put that code into one database and have it change those options for another database.

Something along the lines of:

Code:
ChangeProperty Database.mdb "AllowBypassKey", DB_BOOLEAN, False

I am pretty sure the above won't work, but is there something similar to that will?


Thanks for the help.
 
Come to think of it, the reason why I stopped using .mde files was because I kept recieving errors (program unexpectedly terminated....) when I ran them. Here's what I do. In Access 2002, I first compile the application. I then compact and repair it. Next, I open the file with Access 2000 and create an .mde file. Am I screwing up somewhere in the process? Should I be compling/compacting and repairing in Access 2002 or 2000? If this issue can be solved, then that is all I am looking for.

Thanks again.
 
I strongly suggest to compile and create the .mde with the same access version.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The following is the subroutine for 'ChangeProperty', and was designed to work INSIDE of the database being 'altered'.
You could probably change the 'Set dbs = CurrentDb' with something like: Set dbs = dbengine.opendatabase(path....)

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object
Dim prp As Property
Const conPropNotFoundError = 3270

10 Set dbs = CurrentDb
20 On Error GoTo Change_Err
30 dbs.Properties(strPropName) = varPropValue
40 ChangeProperty = True

50 Change_Bye:
60 Exit Function

70 Change_Err:
80 If Err = conPropNotFoundError Then ' Property not found.
90 Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
110 dbs.Properties.Append prp
120 Resume Next
130 Else
' Unknown error.
140 ChangeProperty = False
150 Resume Change_Bye
160 End If
End Function


"Hmmm, it worked when I tested it....
 
Thank you guys.

The .mde file worked fine after I compiled/compacted in Access 2000. I think that this issue has been solved.

Travil,
Thanks for the code, this is going to be helpful in another part of the database.


Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top