protect my data base window

Y

Yousoft

I set my data base file to startup mode and hide the (Data Base Window), but
my problem I want to protect my data base window to not view, by pressing
(shift+enter ) to the specific data base file.
Thanks
 
B

ben

To disable the database window view via the shit key.

You will need to billed a second database only you have access to it with
the following code.

Make a Public Funtion:
Public Function ChangeShift(strMDBName As String, fChange As Boolean)

On Error GoTo ChangeShift_Err
Dim db As Database, prp As Property
Set db = DBEngine(0).OpenDatabase(strMDBName)
db.Properties("AllowBypassKey") = fChange

ChangeShift_Done:
MsgBox "The proper"
Set db = Nothingty 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set prp = Nothing
GoTo Function_End

ChangeShift_Err:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, _
fChange, True)
db.Properties.Append prp
GoTo ChangeShift_Done
Else
MsgBox "Error # " & Err & " @@" & Err.Description, _
vbExclamation, "Error"
End If

Resume ChangeShift_End
Function_End:
End Function


Then add this code to a command button on click event to diable the "shift
enter"
Private Sub cmdPromptL_Click()
ChangeShift InputBox("Please Enter a Path to the Database.", "Lock"), False

End Sub

Then add this code to a command button on click event to enable the "shift
enter".
(You will want this so you can edit the database.)
Private Sub cmdPromptU_Click()
ChangeShift InputBox("Please Enter a Path to the Database.", "UnLock"), True


End Sub
 
B

ben

Not sure what what happened to my first reply but here it is again.

Make a new database.
Add this public function:
Public Function ChangeShift(strMDBName As String, fChange As Boolean)

On Error GoTo ChangeShift_Err
Dim db As Database, prp As Property
Set db = DBEngine(0).OpenDatabase(strMDBName)
db.Properties("AllowBypassKey") = fChange

ChangeShift_Done:
MsgBox "The proper"
Set db = Nothingty 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set prp = Nothing
GoTo Function_End

ChangeShift_Err:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, _
fChange, True)
db.Properties.Append prp
GoTo ChangeShift_Done
Else
MsgBox "Error # " & Err & " @@" & Err.Description, _
vbExclamation, "Error"
End If

Resume ChangeShift_End
Function_End:
End Function


Then Add these two command button onclick events to Lock(disable shift) and
unlock(enable shift) respectively.


ChangeShift InputBox("Please Enter a Path to the Database.", "Lock"), False


ChangeShift InputBox("Please Enter a Path to the Database.", "UnLock"), True
 
Y

Yousoft

ben said:
Not sure what what happened to my first reply but here it is again.

Make a new database.
Add this public function:
Public Function ChangeShift(strMDBName As String, fChange As Boolean)

On Error GoTo ChangeShift_Err
Dim db As Database, prp As Property
Set db = DBEngine(0).OpenDatabase(strMDBName)
db.Properties("AllowBypassKey") = fChange

ChangeShift_Done:
MsgBox "The proper"
Set db = Nothingty 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set prp = Nothing
GoTo Function_End

ChangeShift_Err:
If Err = 3270 Then
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, _
fChange, True)
db.Properties.Append prp
GoTo ChangeShift_Done
Else
MsgBox "Error # " & Err & " @@" & Err.Description, _
vbExclamation, "Error"
End If

Resume ChangeShift_End
Function_End:
End Function


Then Add these two command button onclick events to Lock(disable shift) and
unlock(enable shift) respectively.


ChangeShift InputBox("Please Enter a Path to the Database.", "Lock"), False


ChangeShift InputBox("Please Enter a Path to the Database.", "UnLock"), True

I follow your code, but I got this message “ compile error, user- defined
type not definedâ€
Please I want know where is the fault.
Thanks for your help
 
B

ben

I am sorry. Something went goofy with my copy and paste of the code.

Replace this part:
ChangeShift_Done:
MsgBox "The proper"
Set db = Nothingty 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set prp = Nothing
GoTo Function_End

With this:
ChangeShift_Done:
MsgBox "The property 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set db = Nothing
Set prp = Nothing
GoTo Function_End

Let me know how it goes.
I will watch this more closely
 
Y

Yousoft

ben said:
I am sorry. Something went goofy with my copy and paste of the code.

Replace this part:
ChangeShift_Done:
MsgBox "The proper"
Set db = Nothingty 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set prp = Nothing
GoTo Function_End

With this:
ChangeShift_Done:
MsgBox "The property 'AllowBypassKey' from" & vbCrLf _
& strMDBName & " was changed successfully to '" _
& fChange & "'", vbInformation, "ChangeShift"

ChangeShift_End:
Set db = Nothing
Set prp = Nothing
GoTo Function_End

Let me know how it goes.
I will watch this more closely

Thank you sir for your reply
Your changes still give me the same message it was showing before &
highlight the second line (Dim db As Database, prp As Property
) Specially in (db As database)
Pls. if you can find where the problem.
Thanks
 
B

ben

Lets make sure you have the correct references loaded.

In the Visual Basic Editor.
Go to "Tools" then "References"

Make sure at minimum the following are checked.

Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft Visual Basic for Applications Extensibility 5.3

If you still having trouble. If you would like to share post some contact
information I can send you a copy of the working database.
 
Y

Yousoft

Dear sir
after checking all the references missing
Still I got this message “run –time error’13’ type mismatch

And yellow highlight on this line showing below:
Set prp = db.CreateProperty("AllowBypassKey", dbBoolean, _
fChange, True)
 
B

ben

That error has me at a loss.
I dont see anything wrong with the code.

Is there a place I can send you a working copy of this database?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top