Password protecting multiple forms

All you really need, like DC was saying, is a table with UserID, Password and Unit. Create a form based on that and put something like this in the code for the login button:
Code:
Dim varunitnumber as integer
If me.txtpassword = dlookup("[Password]","Users","[UserID]='"&me.txtusername & "'" then
VarUnitNumber=dlookup("[Unit]","Users","[UserID]='"&me.txtusername & "'"
Docmd.close acform
docmd.openform Yourformname here,,,"[Unit]=" & varunitnumber 
Else
msgbox "Invalid Username/Password"
Endif
Easy if you can trust people not to muck about behind the scenes. Obviously txtpassword is the password text box on your login form and so on.

It's also possible to do things like hide the database window and toolbars so users can't see the base table or toggle the filter off...

Wonderful! I'll try to do that. Thanks!
 
Where do you put this code though?
 
You would put this in the Login form that you have not yet created.:eek:
 
In the code for the login button? When you've created it, I mean

Guys I have no idea what the login button is....I need a little more detailed instructions. Is it the code builder thing? I've found that before.

Okay created an example login form/database. Now what?
 
The code will go in a button that you create on a form that you create based upon the users table we were speaking about before. The code builder is what you'll use to make the login button do what you want to do... Have a read up above, you'll see
 
Just wondering what the differences between the 50 forms are?
 
Nothing. Just the underlying dataset. Unit A data as opposed to Unit B data.
 
It's not that much of a problem. How are you getting on creating the login form that I was talking about in post 20?
 
It's not that much of a problem. How are you getting on creating the login form that I was talking about in post 20?

I have a table with usernames and passwords. I put some random stuff in there. Then I made a form. Lost from there.
 
An identifier for the unit using it possibly. That would be the extent of it.


http://www.databasedev.co.uk/login.html This is helping some but I have no idea where to put the codes and how to find the places to put the codes etc. :( This just keeps turning into a bigger and bigger headache
You can use one form and filter the Record Source to the Unit that the user belongs to.
 
Each user should be assigned to a Unit.

That would be nice if I knew how to do that.
An example of how:
Code:
 DoCmd.OpenForm "[COLOR=Red]FormName[/COLOR]", , , "[COLOR=Red]Unit = 1[/COLOR]"
 
Hi Epi,

I'd stay well clear of the multiple mde solution as this requires you to make separate mde's for each and every little change take you'll making in the future, plus it relies on the fact that each group will only log on from their particular machines.

You have a few steps to complete so tackle each one separately

1) Firstly you'll need a table with each user’s log-on details such as name and individual password as well as the name of their department.

2) the tables that hold the data from the forms will also need to have a field to identify which department created the data (perhaps you already have relationships to do this)

2) Create a log-on screen so each user has to input their username and password when your system opens

3) There’s a lot of ways to accomplish the next step. I use a hidden field on my main form that holds the department name of the logged on user. Something like CurrentUser() and Dlookup will do the trick for populating the hidden field.

4) Access the data on the on the forms based on a query using the department as the filter criteria.

You’re done.

Also you could if you wanted simply us the and lookup and CurrentUser() right in the query criteria, but I like the idea of letting users change the department data they’re accessing simply by changing the department name on the main form.

SamllTime
 
Hi Epi,

I'd stay well clear of the multiple mde solution as this requires you to make separate mde's for each and every little change take you'll making in the future, plus it relies on the fact that each group will only log on from their particular machines.

You have a few steps to complete so tackle each one separately

1) Firstly you'll need a table with each user’s log-on details such as name and individual password as well as the name of their department.

2) the tables that hold the data from the forms will also need to have a field to identify which department created the data (perhaps you already have relationships to do this)

2) Create a log-on screen so each user has to input their username and password when your system opens

3) There’s a lot of ways to accomplish the next step. I use a hidden field on my main form that holds the department name of the logged on user. Something like CurrentUser() and Dlookup will do the trick for populating the hidden field.

4) Access the data on the on the forms based on a query using the department as the filter criteria.

You’re done.

Also you could if you wanted simply us the and lookup and CurrentUser() right in the query criteria, but I like the idea of letting users change the department data they’re accessing simply by changing the department name on the main form.

SamllTime

Yeah this will be on one server and there are way to many computers for me to mess with. Plus I have ZERO experience in this kind of coding. I know SAS and SPSS. I can make pretty forms in Access and also do databases with relationships, queries, importing/exporting etc. So when people say things like use this code....I don't know where to put that code and how to find where to put it.

1 is done (with example) and 2 isn't an issue. The 2nd #2 is the problem I'm having. If someone could explain this in detailed instructions and not just give me codes that I don't know what to do with I would be sooo appreciative.

Thanks!
 
Ok Lets go back just few steps.
It's VERY important to get this right from the beginning as you'll just create problems for yourself later.

If you have a large number of users, which i think you have, then EVERY user must have their own mde (or accde for 2007) otherwise you're looking at slow performance and corruption issues not far down the line.

That's another issue you'll have to tackle before you go live.

Now the next matter of where to put code. Every object the you create form, button, field, label and so on have their own event properties which you can access from the ribbon under Property sheet or simply double click an object in design view. (We’re all assuming and perhaps hoping you already know this)

Let’s stick with James’s solution so we don’t get muddled up

He’s has already kindly given you the code for the button you’d have on the log-on form.
1) Make sure have a table called Users and with two fields Password and UserID
2) Create a new unbound form.
3) Add two text fields, name them txtusername and txtpassword
3) Add a button on the form
4) Double click to then button (still in design view) and the properties sheet should appear if it’s not already visible.
5) On the property sheet select the EVENT tab and you see the various event options for button
6) select the event called ‘OnClick’ and then click the three dots …
7) If you’re presented with an options box select the Code builder option and you should then be in the screen where you can enter VBA code
8) Copy and paste James’s code between the lines that say something like

Private Sub Command1_Click()


End sub
9) Save the form and run it.
 
Ok Lets go back just few steps.
It's VERY important to get this right from the beginning as you'll just create problems for yourself later.

If you have a large number of users, which i think you have, then EVERY user must have their own mde (or accde for 2007) otherwise you're looking at slow performance and corruption issues not far down the line.

That's another issue you'll have to tackle before you go live.

Now the next matter of where to put code. Every object the you create form, button, field, label and so on have their own event properties which you can access from the ribbon under Property sheet or simply double click an object in design view. (We’re all assuming and perhaps hoping you already know this)

Let’s stick with James’s solution so we don’t get muddled up

He’s has already kindly given you the code for the button you’d have on the log-on form.
1) Make sure have a table called Users and with two fields Password and UserID
2) Create a new unbound form.
3) Add two text fields, name them txtusername and txtpassword
3) Add a button on the form
4) Double click to then button (still in design view) and the properties sheet should appear if it’s not already visible.
5) On the property sheet select the EVENT tab and you see the various event options for button
6) select the event called ‘OnClick’ and then click the three dots …
7) If you’re presented with an options box select the Code builder option and you should then be in the screen where you can enter VBA code
8) Copy and paste James’s code between the lines that say something like

Private Sub Command1_Click()


End sub
9) Save the form and run it.

This is exactly what I was looking for. Thank you!!!!
 

Users who are viewing this thread

Back
Top Bottom