473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dlookup again

64
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

Expand|Select|Wrap|Line Numbers
  1. Dim security As Integer
  2. Dim user As String
  3.  
  4. user = Environ("USERNAME")
  5. Me.txtUser = user
  6. Me.txtUsername = DLookup("UserName", "User", "[UserName]='" & user & "'")
  7.  
  8. If IsNull(DLookup("UserSecurity", "User", "[UserLogin]='" & Me.txtUser & "'")) Then
  9.     MsgBox "No User Security set up for this user. Please contact the Admin", vbOKOnly, "Login Info"
  10.     Me.Command175.Visible = False
  11. Else
  12.     security = DLookup("UserSecurity", "User", "[UserLogin]='" & Me.txtUser.Value & "'")
  13.     If security = 1 Then
  14.         Me.Command175.Visible = True
  15.     Else
  16.         Me.Command175.Visible = False
  17.     End If
  18. End If

The problem when I access as admin it will go on the line 8 until 10

Can anyone help me?
Apr 30 '15 #1
2 1488
jforbes
1,107 Expert 1GB
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:
Expand|Select|Wrap|Line Numbers
  1. Dim security As Integer
  2. Dim user As String
  3.  
  4. user = Environ("USERNAME")
  5. Me.txtUser = user
  6. Me.txtUsername = Nz(DLookup("UserName", "User", "[UserName]='" & user & "'"), "")
  7. security = Nz(DLookup("UserSecurity", "User", "[UserLogin]='" & user & "'"), 0)
  8.  
  9. Dim security As Integer
  10. Dim user As String
  11.  
  12. user = Environ("USERNAME")
  13. Me.txtUser = user
  14. Me.txtUsername = Nz(DLookup("UserName", "User", "[UserName]='" & user & "'"), "")
  15. security = Nz(DLookup("UserSecurity", "User", "[UserLogin]='" & user & "'"), 0)
  16.  
  17. ' Hide Everything First
  18. Me.Command175.Visible = False
  19.  
  20. Select Case security
  21.     Case 1
  22.         Me.Command175.Visible = True
  23.     Case Else
  24.         MsgBox "No User Security set up for this user. Please contact the Admin.", vbOKOnly, "Login Info"
  25. End Select
Apr 30 '15 #2
mrijet
64
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....
May 2 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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...
6
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...
21
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...
8
by: MLH | last post by:
The following SQL returns PRECISELY what I want: SELECT TOP 1 tblCorrespondence.CorrespID, tblOutboundTypes.OTypDescription, tblCorrespondence.OutDate, tblCorrespondence.VehicleJobID,...
2
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...
6
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...
9
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...
15
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.