473,382 Members | 1,657 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,382 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 1487
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.