473,472 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dlookup not working

7 New Member
hi, whats wrong with this code?
Expand|Select|Wrap|Line Numbers
  1.  If Me.txtPassword.Value = DLookup("[User_Password]", "User", "[User_Name]='" & Me.txtUsername.Value & "'") Then
  2.     DoCmd.OpenForm "frmDetails"
  3. Else
  4.     MsgBox "Wrong Log In details!", vbCritical, "Warning"
  5.     Me.txtUsername.SetFocus
  6. End If
  7.  
  8.  
it always highlights the dlookup line whenever i cluck the the login command
Jan 7 '08 #1
4 3221
missinglinq
3,532 Recognized Expert Specialist
I set up a clone of your User table and form with all controls/fields named the same and the code runs perfectly! My first thought would be to double check the spelling of the names of all objects, including the table name. User instead of Users would be all it'd take to break the code, as well as the name of any control/field involved. My only other thought would be corruption of your form, with seems unlikely, given the utter simplicity of it!

Welcome to TheScripts!

Linq ;0)>
Jan 7 '08 #2
andy143vivi
7 New Member
I set up a clone of your User table and form with all controls/fields named the same and the code runs perfectly! My first thought would be to double check the spelling of the names of all objects, including the table name. User instead of Users would be all it'd take to break the code, as well as the name of any control/field involved. My only other thought would be corruption of your form, with seems unlikely, given the utter simplicity of it!

Welcome to TheScripts!

Linq ;0)>
thanks! found the problem my record source is empty, so i use the record to table User, am i doing the right thig here?
Jan 7 '08 #3
missinglinq
3,532 Recognized Expert Specialist
Which record source is empty? User table or the table behind frmDetails?

And I'm sorry, but I don't understand "i use the record to table User."

Linq ;0)>
Jan 7 '08 #4
Minion
108 Recognized Expert New Member
I'm not sure I understand either what you mean by using the table to User, but if you're having problems with the recordsource being empty (ie. getting an error that the Dlookup is null) then you might want to change your code to the following:

Expand|Select|Wrap|Line Numbers
  1. If Me.txtPassword.Value = Nz(DLookup("[User_Password]", "User", "[User_Name]='" & Me.txtUsername.Value & "'") , 0) Then
  2.     DoCmd.OpenForm "frmDetails"
  3. Else
  4.     MsgBox "Wrong Log In details!", vbCritical, "Warning"
  5.     Me.txtUsername.SetFocus
  6. End If
  7.  
This should return a "0" instead of the Null value and save you an error. On a whole I have found that you should just about always trap for Null when using DLookup to avoid errors.

Hope this helps.

- Minion -
Jan 7 '08 #5

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

Similar topics

2
by: Ronny Sigo | last post by:
Hello all, I already put the same question, only now I have more to tell ... Although I used this code before in the same routine (only the fieldname of the table differs) ___ at this point in the...
4
by: Joe | last post by:
I have a table with an sequence (PK) and 2 fields, employee id and status id. Each employee can have multiple records in this table due to multiple status ids assigned. I have a multi-list box...
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...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
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...
3
MSeda
by: MSeda | last post by:
I have a loop that is controlled by a Dlookup statement with two criteria. Both criteria fields are checkboxes. I have tried an assortment of quotation marks in the criteria section and cannot get...
2
by: jonvan20 | last post by:
I have been having trouble with a simple Dlookup command that was Reccommended to me by a nice fellow named Vic, On the other hand I have statements like this that wont run they give me a run time...
0
by: musman | last post by:
hey all, I have tried to use the select statement instead DLookUp function as i have sql server at my backend and access as my front end. But neither DLookUp function is working nor select state...
4
beacon
by: beacon | last post by:
Hi everybody, I'm really hoping this will be the last problem I run into because I don't have much hair left to pull out! :) I have a form that the user will enter a census date (indexed field)...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.