coasterman
Registered User.
- Local time
- Today, 07:14
- Joined
- Oct 1, 2012
- Messages
- 59
I am trying to restrict access to different records using the api username call.
The function is the fosusername() code which I guess everyone will be familiar with.
At the moment all controls on a record are locked unless:
fosusername() = Me.TopicOwnerUserID
This is all working fine but I need to have an exception to the above rule to allow other employees with an equal or higher authority (to the topic owner) to be able to edit the record.
I have added an unbound control with its controlsource set to the [LevelAuthNumber] from the subform which contains details about the Topic owner including their UserId (which is the same as the value returned by fosusername function)and the [LevelAuthNumber]. The LevelAuthNumber is simply a scale from 1 to 20 I have included in the tblAuthorities so I have a unique numeric value to work with.
So really what I think I need is an addition to the fosusername() function which can dive into the table where the authority levels are held and compare the [LevelAuthNumber] in that table of the user viewing the record by their fosusername() and the [LevelAuthNumber] recorded in the unbound control on the main form of the record its self:
Would dlookup be available to me here? Hopefully there is some other way as I can never seem to get my dlookups working properly
I did think that as a work around I could
etc and then compare LevelAuthNumber with Me.LevelAuthNumber.
I don't even know whether that would work but even if it did it seems a ridiculous way to go about it with employees changing levels, leaving etc.
I feel like this is the final major hurdle in my project so I'm hopin you guys can offer some advice to set me off on the final leg.
Thanks for looking
The function is the fosusername() code which I guess everyone will be familiar with.
At the moment all controls on a record are locked unless:
fosusername() = Me.TopicOwnerUserID
This is all working fine but I need to have an exception to the above rule to allow other employees with an equal or higher authority (to the topic owner) to be able to edit the record.
I have added an unbound control with its controlsource set to the [LevelAuthNumber] from the subform which contains details about the Topic owner including their UserId (which is the same as the value returned by fosusername function)and the [LevelAuthNumber]. The LevelAuthNumber is simply a scale from 1 to 20 I have included in the tblAuthorities so I have a unique numeric value to work with.
So really what I think I need is an addition to the fosusername() function which can dive into the table where the authority levels are held and compare the [LevelAuthNumber] in that table of the user viewing the record by their fosusername() and the [LevelAuthNumber] recorded in the unbound control on the main form of the record its self:
Would dlookup be available to me here? Hopefully there is some other way as I can never seem to get my dlookups working properly

I did think that as a work around I could
Code:
Dim UName As String
LevelAuthNumber as Integer
UName = fosusername()
Select case Uname
Case SJYG,HYTH,GHYT,HYJF
LevelAuthNumber= 1
Case HTRD,NBGH,KIUH,SFRT
LevelAuthNumber = 2
Case WRTD,GTYH,HYTD,HYTO
LevelAuthNumber =3
etc and then compare LevelAuthNumber with Me.LevelAuthNumber.
I don't even know whether that would work but even if it did it seems a ridiculous way to go about it with employees changing levels, leaving etc.
I feel like this is the final major hurdle in my project so I'm hopin you guys can offer some advice to set me off on the final leg.
Thanks for looking