By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Dlookup issue

P: 4
I have created a form to lookup components in a table. The problem I am having is the table I have has multiple designations in the same field. Ex CR2,CR4,CR18
If I am looking up a field that has one designation in it I am fine. But if the field has more than one designation in it, my Dlookup returns no information. Some of these fields have more than 50 designations in them. So I am trying to avoid creating new individual records. I will if I have to thou.

Private Sub txtReference_Designator_1_Exit(Cancel As Integer)
Dim X, Y As String
On Error GoTo ERR_txtRef_Desig_1
Forms![frmFailureUpdate]![txtPart_Number_1] = DLookup("LIKE *[COMPANY_PN]*", "Tbl" & [lbCode_Name] & "PartsList", "[REF_DESIG] = Forms![frmFailureUpdate]!txtReference_Designator_1")
Exit Sub
MsgBox "Information not available. Contact Administrator"
Exit Sub
End Sub
Sep 25 '06 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,418
Try with DFirst
or Dlast

it's the same structure as Dlookup

Sep 25 '06 #2

P: 4
thanks I'll try it
Nov 10 '06 #3

Expert Mod 15k+
P: 31,768
Also, look out for your usage of DLookUp. Your parameters are not set up in the correct order.

DLookup(expr, domain, [criteria])
The DLookup function has the following arguments.

Argument Description
expr An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field. In expr, you can include the name of a field in a table, a control on a form, a constant, or a function. If expr includes a function, it can be either built-in or user-defined, but not another domain aggregate or SQL aggregate function.
domain A string expression identifying the set of records that constitutes the domain. It can be a table name or a query name for a query that does not require a parameter.
criteria An optional string expression used to restrict the range of data on which the DLookup function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DLookup function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain; otherwise, the DLookup function returns a Null.
Nov 11 '06 #4

Post your reply

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