Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 6th, 2008, 12:20 AM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Question Forms - Dlookup function

when using Dlookup function, how can i give 2 criteria?
im assuming the following is wrong as its throwing up an error

mesc2 = DLookup("MESC", "MescList", "ComponentID='" & [tempId] & "'", "Size='" & [tempSize] & "'")

in my query when i'm searching for MESC value in the MescList table, i need to specify 2 criteria- componentId and Size (as each component Id can come in several sizes).

how can i do this please!

Reply With Quote
  #2  
Old May 6th, 2008, 12:55 AM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
You CAN have multiple criteria, the trick is in the syntax.
Quote:
The function has three arguments: expression, domain, and criteria. (Note that the criteria argument is optional.)

You use the expression argument to identify the field that contains the data in the domain that you want returned or to perform calculations using the data in that field.

The domain argument is the name of the record set that identifies the domain. It can be a table or a query name.

The criteria argument is an optional string expression that you can use to restrict the range of the data that the DLookup() function is performed on. Note that the criteria argument is identical to the WHERE clause in an SQL expression (except that you do not use the keyword WHERE).

So what you need is:
Code:
mesc2 = DLookup("MESC", "MescList", "ComponentID='" & [tempId] & "' AND Size='" & [tempSize] & "'")
Comments on this post
sbenj69 agrees: yep yep, that's the way
__________________
Experience is the thing you have left when everything else is gone.

Reply With Quote
  #3  
Old May 6th, 2008, 02:29 AM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Thanks don! that worked ...

that made me wonder, i have pretty decent knowledge of sql.. can i use sql codin instead of vb somehow?

Reply With Quote
  #4  
Old May 6th, 2008, 09:28 AM
Toyman Toyman is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 475 Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level)Toyman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 h 52 m 35 sec
Reputation Power: 105
Quote:
Originally Posted by Spand
Thanks don! that worked ...

that made me wonder, i have pretty decent knowledge of sql.. can i use sql codin instead of vb somehow?


I don't think you can use sql for dlookup. If you want to use sql, you may consider using ADO or DOA recordset instead.

Reply With Quote
  #5  
Old May 6th, 2008, 06:00 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by Spand
Thanks don! that worked ...

that made me wonder, i have pretty decent knowledge of sql.. can i use sql codin instead of vb somehow?

There is occasionally an overlap, but they are not at all the same kind of languages. SQL is strictly a database query language that is interpreted by the database engine. It can't do anything outside of the database. VB and VBA are general purpose computer languages that can do all sorts of things, and can have loops and branches, deal with regular files, etc. The big advantage of SQL is that virtually every modern database uses a form of it, although there are slight syntax differences from one engine to another. So you can often use the same SQL code (or just slightly modified) that you wrote for Access, with SQL Server, Oracle, Informix, postgress, MySQL, and on and on. In fact, VBA has to use SQL to get data from Access, even when it wraps it in a function like DLookup().

Reply With Quote
  #6  
Old May 6th, 2008, 10:15 PM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Thumbs up Access on LAN?

that makes things very clear

you gentlemen are helping me out big time in figuring out Access!

Another query. My next project is designing a student db for my dad's animation training institute. I believe Access can not be used to create a DB which can be deployed on a LAN network. Can it?

I figured I will use J2EE and oracle, but as they don't have any full time technical ppl working there, Access would be better for matainance purposes.

Reply With Quote
  #7  
Old May 7th, 2008, 07:14 AM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Question Dlookup fn- spaces in strings

I got stuck with DLookup fn again!

problem is when i try to use it for strings with spaces in between.

mesc1 = DLookup("CommonMesc", "PipingComponents", "ComponentType='" & [temptype] & "'")

The above code works fine when "tempType" contains a single word. But if ComponentType="blind flange" say, it doesn't.
So i tried to put extra quotes:

mesc1 = DLookup("CommonMesc", "11440_Components", "ComponentType=""" & [tempType] & """")

lol so now it works when ComponentType contains 2 words but not more than that!!
i have some components whose names contains 4/5 words. what can i do here please!?

Reply With Quote
  #8  
Old May 7th, 2008, 08:56 AM
rpeare rpeare is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 467 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 7 m 47 sec
Reputation Power: 117
Could I offer a suggestion. If you are looking up by a text description field. I would change that so that it's looking up by the unique identifier for your table. So in your componenttype table you should have some sort of unique identifier. Use THAT field do perform your lookup not the part description.
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #9  
Old May 7th, 2008, 02:18 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by Spand
that makes things very clear

you gentlemen are helping me out big time in figuring out Access!

Another query. My next project is designing a student db for my dad's animation training institute. I believe Access can not be used to create a DB which can be deployed on a LAN network. Can it?

I figured I will use J2EE and oracle, but as they don't have any full time technical ppl working there, Access would be better for matainance purposes.

Access CAN be used for a small number of simultaneous users over a LAN, but there are some limitations. Usually it will be necessary to split the database into two .mdb files, one of which holds all the tables and nothing else, and is located on a shared directory someplace on the LAN, the other .mdb contains everything else (queries, forms, reports, etc.) and links to the tables (File menu, Get External Data, Linked Tables). Each user will have their own copy of the second .mdb located on their work station. Thus, the data all exists in one place and is linked by each of the running applications. This usually works acceptably if no more than 4 or 5 users are likely to be actively using the database simultaneously, and if the network isn't really slow, due to overload from other activity. It does require that each work station has a copy of MS Access installed.

If your operations don't meet those conditions, the next option to consider would be to install MS SQL Server (the Express edition is freeware), then you can use Access as the front-end, much like I described above. This would save you developing a complete application in J2EE or other programming language. Take a look at http://www.microsoft.com/sql/editio...ss/default.mspx

Reply With Quote
  #10  
Old May 7th, 2008, 02:31 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jan 2007
Location: Northern California
Posts: 1,171 don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level)don94403 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 32 m 3 sec
Reputation Power: 251
Quote:
Originally Posted by Spand
I got stuck with DLookup fn again!

problem is when i try to use it for strings with spaces in between.

mesc1 = DLookup("CommonMesc", "PipingComponents", "ComponentType='" & [temptype] & "'")

The above code works fine when "tempType" contains a single word. But if ComponentType="blind flange" say, it doesn't.
So i tried to put extra quotes:

mesc1 = DLookup("CommonMesc", "11440_Components", "ComponentType=""" & [tempType] & """")

lol so now it works when ComponentType contains 2 words but not more than that!!
i have some components whose names contains 4/5 words. what can i do here please!?

Ordinarily, DLookup() is intended to look up data based on a unique value, such as an ID. The documentation states:
Quote:
The DLookup() function returns one value from a single field even if more than one record satisfies the criteria. If no record satisfies the criteria, or if the domain contains no records, DLookup() returns a Null.
Thus, it is probably a bad idea to use criteria that are general descriptions, because if there are duplicates, you will only see the first one. In this case, you probably need to use a Query and provide for the possibility that more than one record will match the criteria.

Reply With Quote
  #11  
Old May 7th, 2008, 10:20 PM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Thumbs up

Thanks for your replies everyone... I guess i'll do all my searches through Id feild to avoid complications.

Don, I'll keep your suggestions in mind when i start that next project!


Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Forms - Dlookup function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |