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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
DLookUp ( )
How do I use a textbox on a form with a DLookUp() function
to display data from a table? |
#2
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |