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

Password on a Tab Control Form 1

Status
Not open for further replies.

LooneyToon

Technical User
Aug 12, 2002
17
IE
Lads,
I have a Tab Control form.
Is it possible to put a password on one of the tabs to restrict access ?

Cheers
LooneyToon
 
Hi

Have not done it before, but I see no reason why not, in the OnChange Event of the tabcontrol

Private Sub TabCtl0_Change()
If TabCtl0.Value = 1 Then
..code in here to check password
if password<>correctvalue Then
TabCtl0.Value = 0
end If
End If
End Sub

Note values start at 0. Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Ken,

What would the &quot;..code in here to check password&quot; be ?
 
Looneytoon

I use a form to retrict access to certain forms in my databases. What I would do is this.

Create a small form called Password with an Unbound text box to enter the password in. Use the input mask in properties to make it a password field.

Also put a command button just below that that says Enter Password and runs a macro when you press the button.

The macro should look like this:

1st Row
Condition: IsNull([Forms]![Password]![YourTextBox])
Action: Stopmacro

2nd Row
Condition: [Forms]![Sign In]![signon]<> &quot;Your Password&quot;
Action: MSGBOX - You have entered an invalid SSN

3rd Row
Condition: ... (Ellipses to use condition from above)
Action: Stop Macro

4th Row
Action: Close - Form, Password (These are the arguements for the action)


The first row is to make sure they don't enter a null value to try and get around the password
The second and third row checks the password and if its not correct, tells them so and puts them back onto the form with the password

The 4th row is the one where it lets them get through to the tab.

On your form with the Tabs, in the onclick event of the tab, Run a macro that opens the Password form

Just in case they don't know the password, give them an option to get out of the form by having a close button that uses GotoControl to go back to a permissible tab. That way they aren't stuck there forever.

If I didn't explain myself, let me know and I will try and help some more. Thanks

Chris
 
Chris,

Just to Clarify!

In the 2nd row the [Sign In]![signon]<>&quot;Your Password&quot;, what are the [sign in] and the [signon] referrring to ?

In the 3rd Row, what do you mean by &quot;Ellipses to use condition from above&quot; ??

Thanks
LooneyToon
 
Heh, oops!

[Signin]![Sign on] is the form that I used to do the same thing although its just to get into a new form, not another tab. That should be:
[Forms]![Password]![YourTextbox]<>&quot;Your Password&quot;

In a macro, if you do not want to type out the same condition multiple times you can use Ellipses to run the exact same condition that is above it. In the above case it would look like this

Condition
[Forms]![Password]![YourTextbox]<>&quot;Your Password&quot;
...

The ... means the exact same thing as the line above it, just a lot less typing.

Hope that helps and let me know how it goes.

Chris
 
Nah Chris,
It didn't work,
when I click on the &quot;Tab Control&quot; to go to the tab that I want to protect, nothing happens, I need to click on the page of that tab once or twice in order to get the password up and running, but it doesn't work for me!

I'll survive without it!!

Thanks a million

LooneyToon!

 
Alright, I found out what happened! I have never tried it with a tab before but I have made it work. What I didn't know was that the onclick event of the tab control is for the detail of that tab. Not the tab itself. But, when you enter a tab, it automatically goes to the first control on that tab. So I call the macro from the on enter property of that control.

I also realized that I forgot to have the macro open the form before it checked for passwords! Thats why it didn't work.

I created a very quick database that has just 4 things in it. 1 form with a control, 1 password form, and 2 macros. Here is my workaround.

I have left everything open so that you can take a look at everything. For password protection you will need to take away some things otherwise you can get around it.

Let me know if it is alright to email the DB to you. Its only 62 KB right now and I can Winzip it as well if you need me to.
 
don't worry about it!
I've worked away without it!
I'm going to have two separate databases, with linking forms, so that way I can have one front end for administrators and one front end for users. I'ts actually easier for me this way, because that means that I can give different views in other parts of the database as well!
Your help has been much appreciated!

Thanks
LooneyToon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top