hfsitumo2001
Member
- Local time
- Today, 10:33
- Joined
- Jan 17, 2021
- Messages
- 394
Can anyone give me the sample of the module/VBA for "GetUserID"?
I have the public fuction like this:Which user ID are you trying to get? Is that the same as the network login or Username?
Function GetAccessTypeHfs()
GetAccessTypeHfs = DLookup("AccessType", "LoginTable", "AutoID =" & GetUserID & "")
End Function
Private Sub Form_Load()
If GetAccessTypeHfs = "Admin" Then
Me.ItemCode.Locked = False
Else
MsgBox "Only Admin can edit itemcode", vbInformation, "Frank's Warning"
End If
End Sub
Hi Isaac, are you saying I need to change the module to read like this?:Change GetUserID to environ("username")
No AutoID is an AutoNumber, that is the primary key in my log in table, Accesstype is the short text typeIn fact you might need single quotes, too. I assume AutoID is a text field ...right?
If so, change to:
etAccessTypeHfs = DLookup("AccessType", "LoginTable", "AutoID ='" & environ("username") & "'")
(copy/paste directly - note i added some single quotes in there)
ut based on what you are saying now, you aren't using GetUserID in any place it makes sense to.Then why are you looking it up by ID in the first place? To answer your question, wherever you are using GetUserID, substitute Environ("username")
But based on what you are saying now, you aren't using GetUserID in any place it makes sense to.
I think your GetAccessTypeHfs is totally wrong..
if you look at on load of the form code, that is the criteria to be able for the Admin to edit the item code, other access type can not. And the USERID for Admin is 1Usually when people want GetUserID, it's either a module with a windows API (which gets the logged-in username), or it's Environ("username") (which also, similarly, gets the logged-in username).
It sounds like you have a second question now which is totally different - I suggest posting a new thread. Sorry, I can't understand what you're trying to do now with the Admin and the 1
What is the password Arnel. To be honest, I am not expert in all of this, I just watched on Youtube and I follow step by step, so my login system is still very simple one. As I already shew that my table fields just consist of , UserID, Name, password, and Accesstype. So I need to study from all of you.i think it GetUserID is related to your Login Form.
see this demo.
password is 1234, for user: arnel
password: common for user: common.
How can you do it MintyUse a property then you aren't having to perform a DLookup every time you use it.
Much neater.
OK Arnel I will try to adapt it to mine. Hopefully there will be no more miss match compile error.password is 1234, for user: arnel
password: common for user: common.