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

Passwording, multi-users 3

Status
Not open for further replies.

ItIsHardToProgram

Technical User
Mar 28, 2006
946
CA
Hello, I don't want to post any useless thread or question, or any already answered question, but I am actually needing help on multi-user passwording.... Its not really how to make a form that allows you to exploit users and etc.... its more or less to Restrain or give access, depending which user is entering the database.... and doing so with a form, not with a whole .net structure..... So basically, I was wondering if there was any way to lock (not hiding, since thats what im already doing, and its really bad)All the forms that the users don't have access to.... if so, I would need a bit of help.....

I presently have a form working with a dlookup on my user table.......

Thanks in adance.
 
Nevermind that last thread, I was returning a long in a string criteria, my bad.

I still need to be enlighten on that last parcel of coding you gave me though

Thank you alot.

Julien
 
Sorry for being stupid, I got what you meant but it returns an error, something about the record not being found, and yes I have changed tbltimesheet to my names.... no_emp is my return for the emp number on tbltimesheet and Well empnumber is being triggered on form_load... maybe thats the problem? I should trigger it before form loads???????
 
Now it works, it selects the timesheet, but I can't execute any macro saying there is an error in the event procedure says that the member already exists in another module from which this one is derived. (sorry for the wrong error msg but I am french >.<)
 
An explination of the last bit of code:

Unless a form is unbound, it has some kind of record source: Usually a table or query. My last bit of code is the SQL you could use for your form's record source. If you open your form in design view then go to it's properties, you should see a field labelled "record source" (first field under the data tab).

In that box, you can point your form to any existing table or query you want; your form is probably already pointing to your timesheet table. Additionally, you can type in some code of your own to define your form's recordset. It would look like this (be sure to use the " " around the code.

Code:
"SELECT * FROM tblTimeSheet AS t WHERE t.[emp_no] = EmpNumber();"

You don't want to execute this code through visual basic as an event - it is simply telling your form what it's record source is. Does that make sense?


~Melagan
______
"It's never too late to become what you might have been.
 
Yes I got that, but when I place a query in the record source (the sql code creating a query) it gives me an error, more precisly saying that the event is the same then an event already in another object, what ever query i put it does that.....
 
If any one has any idea why the SQL returns an error (current expression is already in used in another object or module) I would like to have tips....

I still get the same error
 
I'm wondering of there is some code in another event behind your form that is causing that error?


~Melagan
______
"It's never too late to become what you might have been.
 
Melagan, I actually cleared the error out, See, the problem was not in the referencing as I thought, it was in the relationships... I was linking my Subform which is project and days With my timesheet, when I should have been linking it by my employee sheet for the employee number, since the primary key was there.

The other error I found was in the function. apparantly it was written down has
Code:
Public Function EmpNumber()
'DLOOKUP Function to get Employee Number from
'User table based on user currently logged in.
On Error GoTo EmpNumber_Err

EmpNumber = DLookUp( _
  "[no_emplo]", "tblUsers", "[UserID] = CurrentUser()" _
  )

 EmpNumber_Exit:
   Exit [COLOR=red yellow]Sub[/color]

 EmpNumber_Err:
   msgbox Err.Description
   Resume EmpNumber_Exit

End Function

Sub should have been function, probably got replaced when I was testing the function.

Any how now it works a charm, PHV gave me a SQL that cleared my last problem, Thanks alot for your help melagan.
 
I should have been linking it by my employee
Reread my post stamped 18 Apr 06 17:25 ...
 
Nono but It was linked to the mainform by employee number, but it was directly linked to it with employee number, hence no referential integrety was possible, but linking it to my TABLE employee, made a many to many reference that enabled the relation to take place efficiently, making the SQL possible...

Maybe thats what you meant, but I am only starting so... sometimes i dont get things :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top