Simple DLookup not working. (1 Viewer)

Clayhead22

Registered User.
Local time
Today, 02:37
Joined
Feb 22, 2015
Messages
36
Hi All. I think this could be a formatting issue or doing something simple, incorrectly however i am at the end of my tether. Please be so kind to help.

Enter_Username = the name of the text box on the login page.
Also "Profile field" value is a drop down list selection within the table "Users". Table format is "Short Text"

Code:
Dim Useraccess As String

    Useraccess = DLookup("Profile", "Users", "Username = '" & Enter_Username & "'")
    
    If Useraccess = "Agent" Then
    DoCmd.OpenForm "Agent Dashboard"


It does not throw up any errors however it does not open the form. :mad:
Also just to mention i have ensured i am entering the correct Username and password.
 

Minty

AWF VIP
Local time
Today, 02:37
Joined
Jul 26, 2013
Messages
10,371
Try referencing the form control - Me.Enter_Username
 

Clayhead22

Registered User.
Local time
Today, 02:37
Joined
Feb 22, 2015
Messages
36
Useraccess = DLookup("Profile", "Users", "Username = '" & Me.Enter_Username & "'")

Still no luck :(

The really strange thing is that if i set the "Profile" cell in the table as just text it works fine however if i have it as a lookup IE dropdown (Currently) it does not work.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:37
Joined
Feb 19, 2013
Messages
16,618
Sounds like the problem is with the table - you say the profile field is a dropdown - what is the rowsource? also is the username a dropdown as well? If so, what is the rowsource?

Also have you tried debugging - put

debug.print Useraccess

after the dlookup line - what appears in the immediate window?
 

Clayhead22

Registered User.
Local time
Today, 02:37
Joined
Feb 22, 2015
Messages
36
Porfile looks up what the agent profile should be from another table called lists IE manager, agent ect.

Username is not a dropdown just a username and password box.
Login works fine just wont open the form.



I have just read the link from Minty which explains it just wont work this way.

A little disappointed but will find another way. Thanks guys :)
 

Minty

AWF VIP
Local time
Today, 02:37
Joined
Jul 26, 2013
Messages
10,371
They sound like a good idea - until you actually try and use them in the real world, and they cause more confusion than they are worth as you have discovered.
Simply create a separate table with your lookup data in it, and make a "lookup" combo on the form from it.
 

Clayhead22

Registered User.
Local time
Today, 02:37
Joined
Feb 22, 2015
Messages
36
Simply create a separate table with your lookup data in it, and make a "lookup" combo on the form from it.

Good idea. Iwas starting to use buttons but i like this a whole lot better Cheers
 

Users who are viewing this thread

Top Bottom