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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Shift Key LogOn Bypass 3

Status
Not open for further replies.

LittleSmudge

Programmer
Mar 18, 2002
2,848
GB
A question for A2k using ADO

thread181-391117




. G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
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
 
WOW . Something as simple as ONE SINGLE Dim statment changed and its done.

I'd not realised before that

Code:
Dim dbs As Database
- which is DAO only

could be changed to

Code:
s As Object

and would allow it to work fine.

THAT little trick is going to get a lot of use in MANY other instances I can see.

Thanks foroughifar .


And to prove it :-
You have chosen to recognize foroughifar for a helpful or expert post!
Thanks for letting foroughifar know their post was helpful.

Click Here To Confirm This Action And Give foroughifar's Post A Star


:)

G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
That does seem to work with an Access project.
In Microsoft Access the CurrentDb method establishes a hidden reference to the Microsoft DAO 3.6 Object Library in a Microsoft Access database (.mdb). If you want to use the CurrentDb method in an Access project (.adp) you must set a permanent reference to the DAO 3.6 Object library in the Microsoft Visual Basic Editor.



James Goodman MCP
 
I have tried foroughifar's code but for me it doesn't work.

I think I am putting in in the wrong place (The Form which I call "Welcome" designated in the OpenForm line in the Autoexec macro).

From Startup the Shift Key is not bypassed and I go straight to the Database Manager. I can then open "Welcome" and the "View" Option appears in the Toolbar.
Opening "Welcome" in Design View and then changing to Form View 'Dbs.Properties' was originally not recognised.
So I looked at the References and found "Microsoft Ext ADO 2.7 For DDl and Security". Ticking this solved that problem. But the Shift key was still not bypassed.

The ideal place to put this code would be through the Autoexec macro, using RunCode and selecting the Sub Name (I called it [Bypass Shift Key]) but if I start up without the Shift Key the Sub is not found, and if I start with the key depressed the Database Window opens.

If I try calling it using SetbypassProperty the macro will not save.

I am obviously doing something wrong - can anyone tell me how to get it right?
 
I cant rememeber which thread it was from, but I found a working solution for an adp, & modified it to suit:
Application.CurrentProject.Properties.Add "AllowByPassKey", True


Simple, but it works :) James Goodman MCP
 
Thanks to James Goodman.
It looks as though, with a bit of luck , I can put the finishing touches to my Application and go 'live' :) :) :)!!

I have come up with the following Code which I am sure should work:-

Sub SetProperties()
Dim Dbs As Object
Set Dbs = CurrentDb Application.CurrentProject.Properties.Add "AllowByPassKey", True
Dbs.Properties("AllowByPassKey") = False
End Sub

In Database Manager I have named this "ByPass Shift Key"

But ...... where should it go?

Putting it in the OnCurrent Property of the Form opened by the Autoexec macro has no effect presumably because the key has already been recognised and actioned before the Form is opened. Opening the Database with the key depressed takes me straight to Database Manager and does not open the Form.

I have not been able to get the AutoExec Macro to recognise the Sub, using either the RunCode or RunCommand options. If I enter the Code or Command as [ByPass Shift Key] the Program cannot find it when I try to open. If I use [SetProperties] the macro will not save.

Clearly there is something which I should be doing and I cannot see what it is.

Any help at this stage would be very gratefully received.

Henri P M Mayoux

A computer will always do what you tell it to do - not what you think you are telling it to do.
 
You are using the CurrentDB method within your procedure. Is this delibertate, because it relies on the DAO library? If you use the approach I posted above you can discard the DAO object library.

I have a function, in a standard module, which reverses the AllowByPassKey property. I call it directly from a custom admin menu <which is enabled/disabled based on user login at startup>.

I am not sure exactly, but if you write it as a function, I think you can call it from the AutoExec macro. Remember that once this is set though, it is a permanent change unless it is reactivated by something else. James Goodman MCP
 
James
Thanks again

Looking at your code the ChangeProperty sub was obvously superfluous, so I scrapped this and my other Sub and wrote:-

Function SScreen()
Application.CurrentProject.Properties.Add &quot;AllowByPassKey&quot;, False
End Function

and called it under RunCode, selecting the function through the wizard to make sure I got it right.

Put a stop in the Function - the stop worked, Application.Name showed as &quot;Access&quot; in the Immediate Window; Application.CurrentProject. Name gave the correct project name. So the RunCode call was working.

But on opening the Database -

No effect, the Shift Key still took me through to the DataBase Window.

Change &quot;False&quot; to &quot;True&quot; - same result.


Just as a further check I added two more lines, giving me:-

Function SScreen()
Application.CurrentProject.Properties.Add &quot;AllowByPassKey&quot;, False
Application.CurrentProject.Properties.Add &quot;StartupShowDBWindow&quot;, False
Application.CurrentProject.Properties.Add &quot;StartupShowMenuBar&quot;, False
End Function

Still No Effect: The Shift key goes straight to DataBase Window as before and all the data can be viewed. Without the shift key the View Menu disappears (I did disable it in the Options menu on Startup) but the Menu Bar still appears.

Thinking about this, all the Functions I have used before returned a value for the Function Name,
'SScreen = xxxx'.

I tried to express &quot;AllowByPassKey&quot; as a value but that didn't work either.
'? Application.CurrentProject.Properties.[AllowBypassKey]' in the Intermediate Window produced a message &quot;Data or Object not Found&quot;.

On your last comment - I have no problem with permanence, I don't want the Users to have access either to the Menu Bar or the Database Window at any time. Presumably &quot;permanence&quot; is within the current project only and does not carry over to any other Access Database they may use.

Sorry to be such a pain, but I just seem to be up against a brick wall.

Henri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top