A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

DLookUp ( )



 
 
Thread Tools Display Modes
  #1  
Old August 23rd, 2004, 07:12 PM
David
external usenet poster
 
Posts: n/a
Default DLookUp ( )

How do I use a textbox on a form with a DLookUp() function
to display data from a table?

  #2  
Old August 23rd, 2004, 10:45 PM
Paul Johnson
external usenet poster
 
Posts: n/a
Default

The format for dLookup is:
dLookup(strExpression,strDomain,strWhereCondition)

The parameters are all string values. StrExpression is the table field
whose value you are looking up. StrDomain is a table or saved query object.
If you have spaces in the names of your field or table, you must enclose
them in square brackets as well as quotes: "[Last Name]","[My Table]"

Example of common usage:
dLookup("ZipCode","tblCustomers","CustID=" & me.cboCustomer)

This made-up example assumes you have a combobox cboCustomer on your form
that is based on the numeric CustID field. If the Where Condition includes
a text value, it needs to be spelled with quotes-in-quotes:

dLookup("ZipCode","tblCustomers","CustName='" & me.txtCustName & "'")

Note use of single quotes in third parameter. Some prefer "CustName=" &
Chr(34) & me.txtCustName & Chr(34), but single quotes are enough. It's
harder to see the single quotes in code, but easier to type-- personal
preference applies here.

HTH
Paul

"David" wrote in message
...
How do I use a textbox on a form with a DLookUp() function
to display data from a table?



  #3  
Old August 24th, 2004, 12:55 PM
Michel Walsh
external usenet poster
 
Posts: n/a
Default

Hi,

You don't need to care about the delimiters if you use the syntax
FORMS!FormName!ControlName, and keep it INSIDE the string:

dLookup("ZipCode","tblCustomers","CustID=FORMS!For mNameHere!cboCustomer")


That is working for Dxxx domain functions, and DoCmd methods, but NOT
for CurrentDb (or database objects) methods.


Hoping it may help,
Vanderghast, Access MVP

"Paul Johnson" wrote in message
...
The format for dLookup is:
dLookup(strExpression,strDomain,strWhereCondition)

The parameters are all string values. StrExpression is the table field
whose value you are looking up. StrDomain is a table or saved query

object.
If you have spaces in the names of your field or table, you must enclose
them in square brackets as well as quotes: "[Last Name]","[My Table]"

Example of common usage:
dLookup("ZipCode","tblCustomers","CustID=" & me.cboCustomer)

This made-up example assumes you have a combobox cboCustomer on your form
that is based on the numeric CustID field. If the Where Condition

includes
a text value, it needs to be spelled with quotes-in-quotes:

dLookup("ZipCode","tblCustomers","CustName='" & me.txtCustName & "'")

Note use of single quotes in third parameter. Some prefer "CustName=" &
Chr(34) & me.txtCustName & Chr(34), but single quotes are enough. It's
harder to see the single quotes in code, but easier to type-- personal
preference applies here.

HTH
Paul

"David" wrote in message
...
How do I use a textbox on a form with a DLookUp() function
to display data from a table?





  #4  
Old August 24th, 2004, 10:19 PM
Paul Johnson
external usenet poster
 
Posts: n/a
Default

I like that touch.

Paul

"Michel Walsh" vanderghast@VirusAreFunnierThanSpam wrote in message
...
Hi,

You don't need to care about the delimiters if you use the syntax
FORMS!FormName!ControlName, and keep it INSIDE the string:

dLookup("ZipCode","tblCustomers","CustID=FORMS!For mNameHere!cboCustomer")


That is working for Dxxx domain functions, and DoCmd methods, but NOT
for CurrentDb (or database objects) methods.


Hoping it may help,
Vanderghast, Access MVP

"Paul Johnson" wrote in message
...
The format for dLookup is:
dLookup(strExpression,strDomain,strWhereCondition)

The parameters are all string values. StrExpression is the table field
whose value you are looking up. StrDomain is a table or saved query

object.
If you have spaces in the names of your field or table, you must enclose
them in square brackets as well as quotes: "[Last Name]","[My Table]"

Example of common usage:
dLookup("ZipCode","tblCustomers","CustID=" & me.cboCustomer)

This made-up example assumes you have a combobox cboCustomer on your

form
that is based on the numeric CustID field. If the Where Condition

includes
a text value, it needs to be spelled with quotes-in-quotes:

dLookup("ZipCode","tblCustomers","CustName='" & me.txtCustName & "'")

Note use of single quotes in third parameter. Some prefer "CustName=" &
Chr(34) & me.txtCustName & Chr(34), but single quotes are enough. It's
harder to see the single quotes in code, but easier to type-- personal
preference applies here.

HTH
Paul

"David" wrote in message
...
How do I use a textbox on a form with a DLookUp() function
to display data from a table?







 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dlookup and sql Johnny C. Running & Setting Up Queries 1 August 21st, 2004 07:30 PM
Dlookup Peter Running & Setting Up Queries 2 August 5th, 2004 08:39 AM
DLOOKUP in an external Database gives TYPE Mismatch-Error Reiner Harmgardt General Discussion 1 July 22nd, 2004 09:00 AM
DLookup Jennifer Using Forms 0 June 18th, 2004 07:16 AM
DLookup Function in Queries Jim Running & Setting Up Queries 1 June 10th, 2004 07:07 PM


All times are GMT +1. The time now is 06:18 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.