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 1487
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: 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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |