Hi...can anyone solve this code for me...I don't know why when I log as Admin that I set as Integer which 1 = Admin and 2 = User
Below is the coding of retrieve the data by using dlookup - Dim security As Integer
-
Dim user As String
-
-
user = Environ("USERNAME")
-
Me.txtUser = user
-
Me.txtUsername = DLookup("UserName", "User", "[UserName]='" & user & "'")
-
-
If IsNull(DLookup("UserSecurity", "User", "[UserLogin]='" & Me.txtUser & "'")) Then
-
MsgBox "No User Security set up for this user. Please contact the Admin", vbOKOnly, "Login Info"
-
Me.Command175.Visible = False
-
Else
-
security = DLookup("UserSecurity", "User", "[UserLogin]='" & Me.txtUser.Value & "'")
-
If security = 1 Then
-
Me.Command175.Visible = True
-
Else
-
Me.Command175.Visible = False
-
End If
-
End If
The problem when I access as admin it will go on the line 8 until 10
Can anyone help me?
2 1488
I don't really understand what problem you are encountering. If you would like to clarify what your error is, that might be helpful.
Looking at your code, there are a few things that I would do differently: - Dim security As Integer
-
Dim user As String
-
-
user = Environ("USERNAME")
-
Me.txtUser = user
-
Me.txtUsername = Nz(DLookup("UserName", "User", "[UserName]='" & user & "'"), "")
-
security = Nz(DLookup("UserSecurity", "User", "[UserLogin]='" & user & "'"), 0)
-
-
Dim security As Integer
-
Dim user As String
-
-
user = Environ("USERNAME")
-
Me.txtUser = user
-
Me.txtUsername = Nz(DLookup("UserName", "User", "[UserName]='" & user & "'"), "")
-
security = Nz(DLookup("UserSecurity", "User", "[UserLogin]='" & user & "'"), 0)
-
-
' Hide Everything First
-
Me.Command175.Visible = False
-
-
Select Case security
-
Case 1
-
Me.Command175.Visible = True
-
Case Else
-
MsgBox "No User Security set up for this user. Please contact the Admin.", vbOKOnly, "Login Info"
-
End Select
Thanks for replying..@jforbes
The problem that happen to me was...as you know..my table field for user has been set which Admin as 1 and User as 2....The problem in my coding...it cannot lookup the Admin as 1...they insist to as User = 2...eventhough I put it as Admin, it still go to User which is no = 2....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Don Sealer |
last post by:
I've written this expression for a DLookup function. It works almost
alright.
What I'm trying to do is type in a description and the ID field (number)
populates automatically.
It works almost as...
|
by: Ron |
last post by:
Hi All,
Was just wondering which is faster, a subreport or dlookup.
I've got a report with either 5 subreports or lots of dlookups. The
subreports generally have anywhere from 5 to 12...
|
by: Thelma Lubkin |
last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar:
myVar = _
DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '")
I don't believe that this will work, and I...
|
by: MLH |
last post by:
The following SQL returns PRECISELY what I want:
SELECT TOP 1 tblCorrespondence.CorrespID,
tblOutboundTypes.OTypDescription, tblCorrespondence.OutDate,
tblCorrespondence.VehicleJobID,...
|
by: Alan |
last post by:
OK, I have a table called tblPVDMatch with a list of customerID's in it.
I want to perform a lookup on this table to display a message box if the
CustomerID field on the form matches an entry in...
|
by: ApexData |
last post by:
When I use Dlookup. I am only able to return a single value and
therefore cannot seem to assign a single records (3-field values) to
(3-Variables). I noticed that I can get the 3-field values, but...
|
by: |
last post by:
In my database I have a 'control table' in which basic info is stored about the application, for instance the application's path and the name of the company that is using it. In all of the...
|
by: rleepac |
last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue
This is a table used to...
|
by: alexrubio |
last post by:
{{ Split from: Using DLookUp to prevent duplicates in Form }}
Hi all,
I was just tasked at tweaking the above macro and again I cannot find the right combination... I need to put an...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |