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 this table. Even though I
can see the CustomerID in the table and the corresponding number in the
correct field on the form, it always seems to revert to the else statement's
msgbox (see below). Interestingly, it will output Me.CustomerID as part of
the else statement so I know the value it's meant to be looking for is
correct. This is the code I'm using:
If Me.CustomerID = DLookup("Custom erID", "tblPVDMatc h") Then
MsgBox "Match!" & Me.CustomerID
Else
MsgBox "No match!!" & Me.CustomerID
End If
What am I doing wrong?
Thanks
Alan 2 2053
You need to specify criteria. The way you have written it the dlookup
will return the very first record in the tblPVDMatch every time. It
won't even look at the other records.
Check out this Microsoft KB Article on DLookup http://support.microsoft.com/kb/208786
Based on your description it should be written: (Assumes that
CustomerID is a number)
if not isNull(DLookup( "[CustomerID]", "tblPVDMatc h", "[CustomerID] = "
& Me.CustomerID)) then
MsgBox "Match!" & Me.CustomerID
Else
MsgBox "No match!!" & Me.CustomerID
End If
Cheers,
Jason Lepack
Alan wrote:
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 this table. Even though I
can see the CustomerID in the table and the corresponding number in the
correct field on the form, it always seems to revert to the else statement's
msgbox (see below). Interestingly, it will output Me.CustomerID as part of
the else statement so I know the value it's meant to be looking for is
correct. This is the code I'm using:
If Me.CustomerID = DLookup("Custom erID", "tblPVDMatc h") Then
MsgBox "Match!" & Me.CustomerID
Else
MsgBox "No match!!" & Me.CustomerID
End If
What am I doing wrong?
Thanks
Alan
You need to specify criteria. The way you have written it the dlookup
will return the very first record in the tblPVDMatch every time. It
won't even look at the other records.
Check out this Microsoft KB Article on DLookup http://support.microsoft.com/kb/208786
Based on your description it should be written: (Assumes that
CustomerID is a number)
if not isNull(DLookup( "[CustomerID]", "tblPVDMatc h", "[CustomerID] = "
& Me.CustomerID)) then
MsgBox "Match!" & Me.CustomerID
Else
Thanks Jason, I see where I was going wrong now.
Thanks again
Alan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KLAU |
last post by:
I have a field that retrieves information from an expression in a
query. I have used a DLookup function to get the calculated field
from the query. However, the relationship is 1-to-many so one site
could have many units. How do I have the DLookUp field value change
to a newly calcuated field when I navigate through the units? please
see...
|
by: David B |
last post by:
I have a Public function which creates a back up copy of a back end.
It works fine with the source path and source file as C:\folder\etc. I thought
I would try to store the paths in a table
so that any future changes could be made in the table rather than going into the
code.
I have been trying to get DLookup to work as below. Any reason...
|
by: Tony Williams |
last post by:
Does DLookup work in an expression in a query? I have this expression
-(DLookUp("","tblmaintabs","= "))
Which works fine as a calculated control on a form but when I try to use it
in a query as an expression I don't get any result. I want to use the Sum of
the result in a query on which I will base a report.
TIA
Tony
|
by: MLH |
last post by:
I have tried using DLookUp in this manner...
If DLookUp("","tblClients","='2021234567'") Then
MsgBox "Found it!"
End If
I am wondering if that is a misuse of the DLookUp command?
Type mismatch errors keep popping up. Take a look at this
I typed in the immediate window...
|
by: c.kurutz |
last post by:
Hello everyone. I have a problem with looking up pricing. Here is
what I have so far:
TABLES
tblItems:
itemid
itemdescription
itemunit (each, roll, square foot)
location1price
| |
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 won't be at a machine with
access to Access for a while, so can someone please tell me how to write
this?
thanks, --thelma
|
by: sparks |
last post by:
If Not IsNull(DLookup(, "tblDemographic", " =
""" & Me.Text9 & """")) Then
Cancel = True
MsgBox "Duplicate Value is Not Allowed"
ActiveControl.Undo
DoCmd.RunCommand acCmdUndo
End If
I try to do this but when you enter a text value such as A you get
|
by: RoadrunnerII |
last post by:
Hi All
I am new to this forum and still learning MS Access. Hoping this is the right place to ask If not please let me know!
Looking for some help with the SQL statements in Access 2003 with the tables backended into MS SQL Server 2005
The queries work fine but cause the forms to be quite slow if I leave them as is.
If I convert the Queries...
|
by: Breezwell |
last post by:
This is probably a simple question for someone out there.
I understand that the DLookup function takes has the following syntax:
DLookup(expression,domain,)
From what I have read, domain can be a table or query.
I have no problem getting the function to work when I use the actual name of a table for the domain. My question is, can I...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |