Trying to figure out someone elses code

Ziggy1

Registered User.
Local time
Today, 13:50
Joined
Feb 6, 2002
Messages
462
I'm trying to figure out a database created by somone else. They are no longer around to manage the database. The database loads with the shift key disabled.

I have imported all the objects into a new database so I can study the code to find out where the "Escape" is to get into the background.

but the one thing that puzzles me is I get this error when I load the form...Compile error..." User Type not defined"

The error stops on Dim Mydb As Database Yet there is to "Database" type

Also I am curious, if I import all the objects, what doesn't come accross? Because I thought if I imported everything then the database would still open the same way. But it doesn't I get the error?

The database is heavily coded, and I can't post it

this is the procedure that errors which I figure is also the one that prevents me from getting into the background. Can anyone interpret it for me also?

Public Sub lockup(b As Boolean)
Dim Mydb As Database
Dim prpNew As Property
Dim i As Integer
Dim strprop(8)
' b = ((UNAM = "Joe") Or (UNAM = "other"))
'' b = True
' If b Then MsgBox "locks!" Else MsgBox "Unlocks!"
On Error GoTo Err_Property
strprop(0) = "StartupShowStatusBar"
strprop(1) = "AllowBuiltinToolbars"
strprop(2) = "AllowFullMenus"
strprop(3) = "AllowBreakIntoCode"
strprop(4) = "AllowSpecialKeys"
strprop(5) = "AllowBypassKey"
Set Mydb = CurrentDb()
For i = 0 To 5
Mydb.Properties(strprop(i)) = b
Next
Exit Sub
Err_Property:
' Error 3270 means property not found, so Create:
If DBEngine.Errors(0).Number = 3270 Then
Set prpNew = Mydb.CreateProperty(strprop(i), dbBoolean, b)
Mydb.Properties.Append prpNew
End If
Resume Next

End Sub
 
1 thing that doesn't come across, and the likely cause of your error, is the references set in the VBA editor, Tools/References. Another is the settings in Tools/Startup in Access (startup form, etc).
 
the lockup routine is probably called from the switchboard/startup form load or open event, by passing in a parameter (b - the boolean)

the commented rows are presumable joe attempting to set b directly to verify the effect.

If b is true, then the startup properties are set as enabled, for developer access. If false, they are off to protect the dbs. Some of these are a bit tricky as they don't set the CURRENT session. but set the properties for the SESSION AFTER.

YOU SHOULD FORCE b to be true immediately, so you don't lock yourself out inadvertently, at least temporarily. Uncomment the line

'' b= true

The error on mydb as database may be because you are using ADO, and the developer used DAO - try setting the DAO reference above the ADO reference.
 
Thanks guys, Yes checking of the DAO and putting it in front of the ADO did the trick.

I'm still trying to figure out how to get into the design view. I am not to sure what portion of the code does it. There are 2 forms, 1 is the startup via an AutoExec macro. That one is like a splashcreen and triggers the second one. The second one has several events , I can post the code but it is quite long
 
if you can see the lockup code, uncomment the b=true line, to give you full control over the dbs. You may then need to close and open the dbs twice. Eventually you should be able to get into the database. Do a CTRL-H over the word lockup and search for it in the project. This should open the code window where it is used - I think it will be in the open or load event of thestartup form.
 
The startup form calls the lockup routine, I am not able to get to the code window to un comment " b=true ". I just don't know what event has to happen for the code to fail, or toggle off the procedure?

Note: I can edit in the database that I have imported things into, but I need to understand what the switch is to let me get into the design of the original. I supposed I can just do what i need to do in this one and then make it the main. I would feel better knowing what the trigger is


Option Compare Database

Private Sub cmdExit_DblClick(Cancel As Integer)
DoCmd.Close
End Sub

Private Sub Form_Open(Cancel As Integer)
Call lockup(True)
' Cancel = True
End Sub

Private Sub Form_Timer()
On Error Resume Next
MsgBox "stop"

DoCmd.OpenForm "frmPointOfSale"
End Sub
 
My guess is there is a Lockup() procedure in a standard module.
 
how can you see this code, and not be able to edit it

how big is the database? Can you post it?

If you have been able to copy the objects, it looks like your developer safeguarded his design merely to prevent its advertent change, not to keep everyone out permanently

If you can copy everything into a new dbs, why can't you change your copy, and then replace the original with your copy.
 
You might like to check my database from this thread. Here, I have adapted someone else's code to suit my database needs, and, instead of a password switch to disable or enable the key, I use a hidden button to give me immediate access. Read the post carefully, then take a copy and see if it's what you're after.

If you want to copy the security aspect only, you'll need the module BypassKey, the macro Backdoor, and a button (that will be hidden in the final version) somewhere in your database that calls the macro. Be aware that my macro is set to close the specific form the button sits on, so, if yours is to be different, you will need to either code the button in VB, or change the macro's target form.

If you have any questions, feel free to PM me.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom