[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Help in locking down database

Posted on 2004-04-21
13
Medium Priority
?
401 Views
Last Modified: 2008-02-01
Hi,

I'm trying to "lock" the db down so that the users cannot get into the db objects (forms, tables, modules, etc...).

I've created a new module and paste this code:

Sub SetStartupProperties()
    ChangeProperty "StartupForm", dbText, "YourFormHere"
    ChangeProperty "StartupShowDBWindow", dbBoolean, False
    ChangeProperty "StartupShowStatusBar", dbBoolean, False
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
    ChangeProperty "AllowFullMenus", dbBoolean, False
    ChangeProperty "AllowBreakIntoCode", dbBoolean, False
    ChangeProperty "AllowSpecialKeys", dbBoolean, False
    ChangeProperty "AllowBypassKey", dbBoolean, False
    ChangeProperty "AppTitle", dbText, "Application Title Here vs1.2"
    Application.RefreshTitleBar
End Sub

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

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

Change_Bye:
    Exit Function

Change_Err:
    If ERR = conPropNotFoundError Then  ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function

The key line of code here is this

    ChangeProperty "AllowBypassKey", dbBoolean, False
----------------------------------------------------------------------------------------------------------------

but it throws me a type mismatch error.
The error happens on this line:
dbs.Properties(strPropName) = varPropValue

and it throws the "type mismatch" on  
Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)

Just to retrace my steps. I created a module and copy paste the sub and the public function into it. I've insert ChangeProperty "AllowBypassKey", dbBoolean, False into the form_load() of the switchboard. Right? Where have i gone wrong?
0
Comment
Question by:xhenkaii
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 10

Expert Comment

by:eternal_21
ID: 10885760
Try,

     ChangeProperty "AllowBypassKey", dbBoolean, 0
0
 

Author Comment

by:xhenkaii
ID: 10885797
I still have the type mismatch error.
0
 
LVL 10

Accepted Solution

by:
eternal_21 earned 200 total points
ID: 10890726
This code worked for me... What version of Access are you using?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:xhenkaii
ID: 10895161
well i'm using access 02 but my program is in access 2000 format.
0
 

Author Comment

by:xhenkaii
ID: 10895264
it still throws me the type mismatch error even when i convert to access 02 format. help!
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 10895723
I'm pretty sure I solved it, and then I locked myself out of the database...
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 10895744
Change the,

  Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)

to

  prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)

And it should work.  And please make a backup of the database first.... :)
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 10895746
Or replace the next line with:

  dbs.Properties.Append dbs.CreateProperty(strPropName, varPropType, varPropValue)
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 10895756
And change the YourFormHere in,

  ChangeProperty "StartupForm", dbText, "YourFormHere"

To a form that actually exists in your project...  Oh yeah, did I mention making a backup copy first?
0
 

Author Comment

by:xhenkaii
ID: 10896130
well i got it to work now. just shifted the piority of the DAO reference to the top.
(O___O)
i'm bugged about it.
Since i cant take back the points, i'll split it the nice people who tried to help me. =)

Xhenkaii
0
 

Author Comment

by:xhenkaii
ID: 10896147
eternal_21,

 dbs.Properties.Append dbs.CreateProperty(strPropName, varPropType, varPropValue)
This dont work. Gave me an error with the Append dbs statement. End of statement expected.

ChangeProperty "StartupForm", dbText, "YourFormHere"
I've changed it already.

prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
nv tried this... hahaha

anyway, i place a "ChangeProperty "AllowBypassKey", dbBoolean, True" on a dbl_click() abel in a form. So i'm able to activite the SHIFT key to edit my database. heh. Thanks anyway. The pts are urs.
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 10896181
Thanks, xhenkaii.  But if you feel that you have solved the problem yourself, place a post in Community Support, and they will refund your points!
0
 

Author Comment

by:xhenkaii
ID: 10905818
It's no prob for the points with me, eternal. My way of saying thanks for helping.
Cheers!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

656 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