473,326 Members | 2,148 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,326 software developers and data experts.

Code almost there!

DS
This code almost works, The only problem, is that it always Opens the
"Invalid ID" form whether the ID is valid or not, what am I doing wrong?
Thanks
DS
If Display = DLookup("EmployeeID", "Employees") Then
DoCmd.RunMacro "Log On"
Else
DoCmd.OpenForm "Invalid ID"
End If
Nov 13 '05 #1
2 1028
"DS" wrote
This code almost works, The only
problem, is that it always Opens the
"Invalid ID" form whether the ID is
valid or not, what am I doing wrong? If Display = DLookup("EmployeeID", "Employees") Then
DoCmd.RunMacro "Log On"
Else
DoCmd.OpenForm "Invalid ID"
End If


DLookup, unless you include a criteria, will always return the "EmployeeID"
of the first record physically stored in "Employees". If that is not what is
in [variable|Control|?] Display, you will very correctly open the
"InvalidID" form.

Clarify by explaining what is Display, how does a value get there, and how
you thought you were selecting a record in "Employees", and perhaps someone
can offer suggestions.

If you expected this to be appended to an existing thread, it wasn't, and
those details are not obvious to me.

Larry Linson
Microsoft Access MVP

Nov 13 '05 #2
What you are missing from your Dlookup is the criteria.

It should look something like:
if display = Dlookup("EmployeeID","Employees",EmployeeID =
Criteria_goes+here") then........

Mark
"DS" <bo******@optonline.net> wrote in message
news:Zj*********************@news4.srv.hcvlny.cv.n et...
This code almost works, The only problem, is that it always Opens the
"Invalid ID" form whether the ID is valid or not, what am I doing wrong?
Thanks
DS
If Display = DLookup("EmployeeID", "Employees") Then
DoCmd.RunMacro "Log On"
Else
DoCmd.OpenForm "Invalid ID"
End If

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
14
by: Ian Richardson | last post by:
I'm writing a large Javascript application (uncompressed source around 400K) which is doing almost all the initialisation it needs to in a just-in-time manner. However, I have included an option...
6
by: Mario T. Lanza | last post by:
Greetings, I don't know about you guys but on many occasions I've asked myself whether or not someone else has solved a particular programming issue -- whether or not they developed a clever...
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
15
by: Enzo | last post by:
Hi Ng, It's possible to protect the source code of a js file? With PHP? Thanks in advance! Enzo
25
by: Delta | last post by:
Drop Down Menu Mozilla : work well widowed elements such as drop downs, except for flash movies IE : work well so far http://pwp.netcabo.pt/falmartins/index.htm
24
by: Gaijinco | last post by:
I found one of that problems all of us have solve when they begin programming: given 3 numbers print the greater and the lesser one of the set. I was trying to remember the if-then-else...
239
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my...
64
by: Bayazee | last post by:
hi can we hide a python code ? if i want to write a commercial software can i hide my source code from users access ? we can conver it to pyc but this file can decompiled ... so ...!! do you...
55
by: lovecreatesbea... | last post by:
Do you check all error conditions for all library calls in you code? Is it necessary to check all errors? Is it convenient to check all errors (or how to make code clean and readable with mass of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.