CodeCurious
New member
- Local time
- Yesterday, 19:16
- Joined
- Oct 26, 2012
- Messages
- 7
I'm writing a function that mimics login behavior for an Access database. Here's an overview:
- User enters a login ID in a textbox (txtLogin) in a form
- VBA Public Function uses DLookup to lookup the user's role in a table in the database, based on the value in txtLogin, and stores it in a string variable (sRole).
So far so good. The function is properly retrieving the user's role based on their login ID. But then I'd like to make some decisions based on the value of sRole. For example, if the user role is "NotAdmin", I'd like to hide a tab control that lists admin functions. When I use the code below, the compiler seems to think that "NotAdmin" is an undefined variable rather than the value of a declared string variable (sRole):
If sRole = NotAdmin Then
do something to make admin tab invisible
End If
This is the error message I get: "Compile error: Variable not defined" and the compiler seems to have choked on NotAdmin.
I'm new to VBA, so greatly appreciate any help you can provide.
- User enters a login ID in a textbox (txtLogin) in a form
- VBA Public Function uses DLookup to lookup the user's role in a table in the database, based on the value in txtLogin, and stores it in a string variable (sRole).
So far so good. The function is properly retrieving the user's role based on their login ID. But then I'd like to make some decisions based on the value of sRole. For example, if the user role is "NotAdmin", I'd like to hide a tab control that lists admin functions. When I use the code below, the compiler seems to think that "NotAdmin" is an undefined variable rather than the value of a declared string variable (sRole):
If sRole = NotAdmin Then
do something to make admin tab invisible
End If
This is the error message I get: "Compile error: Variable not defined" and the compiler seems to have choked on NotAdmin.
I'm new to VBA, so greatly appreciate any help you can provide.