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

VBA Access Table Passwords?

Status
Not open for further replies.

FlashMax

Programmer
Dec 30, 2002
42
US
Two parts to this question.

1) Can you create VBA for a table only?
2) Can you create a form in VBA on a table that will only make the table visible if the correct password is entered?

Reason: I need to make certain tables viewable to only certain people. I've created tables that my employees can enter their time in and tables that I can see all the times and forms that I can display the times in. However, I don't want Employee A to be able to see Employee B's time sheet.
 
How are ya FlashMax . . .

Assuming you have a function named [blue]PWDOK()[/blue] that returns true if password is verified, you'd have:
Code:
[blue]   Dim Show As Boolean
   
   [purple][b]Show[/b][/purple] = PWDOK("password") [green]'returns true if password ok![/green]
   Application.SetHiddenAttribute acTable, "tblAccounts", [purple][b]Show[/b][/purple][/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thank you very much TheAceMan1. That looks like the perfect solution. I just have one problem. I am very proficient with many different languages but VBA is not one of them. I really feel bad for asking--I don't want you to have to put forth more effort in correcting my ignorance than you want--but I'm not sure how to write the PWDOK function. I also don't know where to append the code. Do I need to create a button to attach it to? I really don't know enough about using VBA with Access to even ask where to put the code.

I would greatly appreciate your help. My ignorance is embarrassing, but I need a little more help to get this working.

Thanks,

Max
 
FlashMax . . .

What I posted was the quickest feasible answer I could think of. However ... there's alot to consider in the schema you require.

Some assemblence of your table structure, fieldnames and relationships are required. In fact ... it would cut down on alot of questions if you could upload a scaled down model of what you have. A good site to do this with is 4Shared. If you decide to upload and your using access 2007, be sure to convert to 2003 before you do.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
TheAceMan1,

I have uploaded the file to 4shared:
I have created a very simple version, but for the most part it is what I want a larger version to look like, except with more queries and reports. Basically, the structure that I want is this: Emily's time sheet hides the data and prompts for a password before showing the info; the same goes for David's time sheet and the queries/reports. I don't want David to be able to see how much time Emily is working, and for accounting purposes I will probably include Emily's and David's rate on their sheets, which they obviously don't need to share with each other. Is this possible?

Thank you for your help.

Max
 
FlashMax . . .

Your skills as a developer are showing![surprise] Your design schema (as I thought) is all wrong. You also need some way for employee's to sign in and have their passwords checked. The [blue]database password[/blue] won't do as its [blue]static[/blue] to all, and [blue]access security[/blue] is quite a bit out of your league. Also ... if your VBA shills are down, you have a very tough fight ahead. The outline that follows is based on the following general tables:

[tt][blue]tblEmployees
************
EmpID as AutoNumber PrimaryKey
FName as Text
LName as Text
ScnName as Text [green]'ScreenName[/green]
PWD as Text [green]'Password[/green]
ADMIN as Yes/No

tblProjectTime
**************
ProjID as AutoNumber PrimaryKey
EmpID as Long [green]'ForeignKey[/green]
Project as Text
Hrs as Single[/blue][/tt]
[ol][li]When the database is 1st opened the database window is completely hidden and remains so until an admin is detected.[/li]
[li]The 1st form to open (automatically) is the login form. ScreenName and PWD are entered here and via a button they are lookedup to see if they exist. If they exist the [blue]EmpID[/blue] of that person is used to filter tblProjectTime. If they don't exist the user can try again or the db can be closed.[/li][/ol]
To see the effect of hiding/showing the db window, make a new form with two buttons. In the [blue]On Click[/blue] event of the button to [blue]show[/blue] the db, copy/paste the following:
Code:
[blue]   DoCmd.SelectObject acTable, , True[/blue]
... and for the [blue]hide[/blue] button:
Code:
[blue]   DoCmd.SelectObject acTable, , True
   DoCmd.RunCommand acCmdWindowHide[/blue]
Open the form and restore down the form so you can see the db window and test the buttons.

For your reference: Fundamentals of Relational Database Design

Since you have to start over with your table schema hop over to forum700 and explain what you need there.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I have been a programmer much longer than I have been a database developer. I see the error of my way. As I suspected--and your "harsh" words echo--I didn't even know how to approach the idea; however, that is mostly because I don't know much about Access. I thought that it might be a good program to tackle this problem. Maybe it is, maybe it isn't, that is yet to be proven to me. My other option is to buy software that doesn't fit what I want and isn't flexible enough to adapt to me. *Sigh*
 
FlashMax . . .

I wasn't trying to sound this way or that ... let alone harsh. Just being direct.

[blue]Yes![/blue] ... what you require can be done in Access. Thats why I've redirected you over to forum700. All DB design starts with the development of [blue]Tables & Relationships[/blue]. This part of your development determines how easy or hard it will be (down the road) to complete your schema.

I'd [blue]go over the reference I provided[/blue] if I were you before you make your 1st post there. This will enlighten you and put you in contact with what things are called ... aka the lingo.

Since you are a programmer you should easily pickup VBA. You just have to get use to the commands available to you.

All in all it really should be quite easy for you! Just take your time in understanding as it comes ...

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top