473,797 Members | 2,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DLookup from a query criteria trouble

21 New Member
[I'm new here]


Access 03

I'm currently having an issue using Dlookup when trying to reference a query (criteria syntax)

Currently I have 1 table, which is L_Emps (which contains Employee_ID as my key (numeric), First_Name, and Last_Name (as text).

My query is Query1 which is the following:

Expand|Select|Wrap|Line Numbers
  1. SELECT L_Emps.Employee_ID, L_Emps.First_Name, L_Emps.Last_Name
  2. FROM L_Emps
  3. WHERE (((L_Emps.Employee_ID)=[ID:]));
I have one form that is named L_EmpsForm. It is basically three bound fields that references Query1.

What I'm trying to do is have an onclick button return the ID that was returned from the query.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command6_Click()
  2.  
  3. ID = DLookup("[Employee_ID]", "[Query1]", "[Employee_ID]=" & [Forms]![L_EmpsForm]![Employee_ID])
  4.  
  5. MsgBox ID
  6.  
  7. End Sub 
This is just a test database to try to teach myself how to use DLookup, but it isn't going so well. I can get DLookup to work fine if I use a static query, but whenever I prompt for the input, I usually get the "You canceled the previous operation" error. I've read up that some of the field references could be off, but I'm unsure as to what exactly.

I know it is a tad redudant to have the Onclick button return the value that is obviously right in front of me when I run the form, but I actually plan on passing the table information into different directions once I actually figure out Dlookup.



Advice?


-DH22
Aug 29 '08
30 7286
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi again. No harm in experimenting - it all adds to your Access experience!

If you could post a small sample of your data from the table holding the directory and suffix fields - real if possible, disguised a bit if the data is sensitive - this will help us to understand how your data is really structured (it's difficult to get a handle on it at this remove).

There are plenty of ways to pick files from Windows API file dialogues that may well be the way to go to resolve your issues, but until we see your data it is really difficult to advise you further.

Thanks

-Stewart
Sep 4 '08 #21
DH22
21 New Member
Hi again. No harm in experimenting - it all adds to your Access experience!

If you could post a small sample of your data from the table holding the directory and suffix fields - real if possible, disguised a bit if the data is sensitive - this will help us to understand how your data is really structured (it's difficult to get a handle on it at this remove).

There are plenty of ways to pick files from Windows API file dialogues that may well be the way to go to resolve your issues, but until we see your data it is really difficult to advise you further.

Thanks

-Stewart
Alrighty, here's a very small example, only three records but that's basically it.
Sep 5 '08 #22
Stewart Ross
2,545 Recognized Expert Moderator Specialist
No sign of the three records so far... -S
Sep 5 '08 #23
DH22
21 New Member
No sign of the three records so far... -S

Yeah, sorry, Stewart. As I was adding the zip as an attachment, I got called away to a very long meeting. Ooi.


I'll be adding the zip to this post.

This is just mock information for security reasons, but the database reflects the real one closely.
Attached Files
File Type: zip db2.zip (12.7 KB, 135 views)
Sep 5 '08 #24
DH22
21 New Member
Hopefully the attached dbase is what you were asking for. :)
Sep 9 '08 #25
DH22
21 New Member
What about a filter?

I really don't know much about it, but could that help out? It would make the combo box less busy, too.
Sep 10 '08 #26
Stewart Ross
2,545 Recognized Expert Moderator Specialist
I will review the DB, DH22, as time allows; I'll post back when I have done.

-Stewart
Sep 10 '08 #27
DH22
21 New Member
Take your time, I'm stumbling through with ideas, myself. Nothing ventured, nothing gained!



-DH22
Sep 11 '08 #28
DH22
21 New Member
Perhaps using the Query as a Make Table query and then running the form on that result? That would narrow it down.
Sep 17 '08 #29
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi DH22. Sorry for the delay in responding; I can only look at the sample DB in my own time, and now that I've done so I find I have no new ideas to offer I'm afraid. I think the simplest solution is to use a series of cascading combo boxes to filter your file lists - selecting by account, folder and so on. Generating another intermediate table is unlikely to help.

The Windows file dialogues don't really help either, because unless these could be filtered in some way users will still be presented with lists of files in the normal tree-like view - and with the number of files involved in your application this would be an overwhelming list for individuals to scroll.

Cascading combos seems like the only viable answer to me. We have a HowTo article on Cascading Combo/List Boxes linked here which provides further information.

-Stewart
Sep 19 '08 #30

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

Similar topics

1
20805
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 example below: On the Form: A site can have many units.
4
21106
by: ShyGuy | last post by:
I have a table with 4 fields. Three are used for criteria. I can get the DLookup to work with 1 criteria with the following but can't get it to work with 2 or three. NumofAppts = DLookup("", "LookUpAppts", " = " & Forms!!NumofPeople) Can someone tell me how to add multiple criteria? I tried "And" but it doesn't seem to work.
7
2258
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
8
4320
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb Klms Distance Jones Melbourne 500 Harrison Sydney 200 Ford Brisbane 700 Jones ...
2
2347
by: chris.thompson13 | last post by:
I am having a problem setting the criteria part of the DLookup method correctly and am consequently getting an error message. I have a database of staff duties, part of which is a query (qryDaily) that returns all staffs duties for a selected day.e.g. Fullname Duty Name1 E1 Name2 Sick Name3 Pwk N2
1
2435
by: MLH | last post by:
I have a query that looks up records in tblReturnReceipts and other related tables. One of the other tables is tblCorrespondence. The resulting dynaset consists of five records. Each has a unique field value and each has a unique field value. I would like to add an additional field to the query that performs a DLookup for some other stuff - using the query's value in the DLookup's criteria section. Of course, I'm having difficulty...
3
2457
by: hrreece | last post by:
I am trying to use the Dlookup expression in a macro to pull the value from the "Price" field in the following query. The query works fine and the Dlookup function did as well until I added a new field to the "Contracts" table called "ContractYear". SELECT Contracts.ID, Contracts.Commodity, Contracts.Date, Contracts.ContractYear, Contracts.Option, Contracts., Contracts.Bushels, Contracts.Price, Contracts. FROM Customer INNER JOIN Contracts...
2
3664
by: Denise | last post by:
Front end is Access 2002, back end is linked Oracle tables. My users need to describe things in feet and inches and want to use the standard ' and " abbrevations. On a testing form I go to a record with double or single quotes in the location description and click a button to see if Access can tell me the ID number and find its way back to the original record. When the text contains double quotes the FindFirst works but the Dloookup...
3
1394
by: Demosthenis | last post by:
Hello, I am trying to seto up a Dlookup in a query. My Dlookup field will retrieve data from a second query. The match criteria is the W field. This dlookup up process has to retrieve 24 different values from the second query (Query5). Unfortunatelly the function always brings the first value of the 2nd query for all the 24 fields. My formula is the Expr10: IIf(="Stock4";dLookUp("SumOfExpr2";"Query5";"=" & ".");). Is it something...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10205
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9063
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4131
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
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.