Look up

R

Rpettis31

I have a form that an item number can be entered. I would like the item
number to be entered and the description to populate the item description. I
have read that using a dlookup is a bad thing (not that I know how to code
that).

The item and descriptions are on an item master tblItemMaster.
 
Z

ZigZagZak

There is nothing wrong with using dlookup. I use it on all of my databases.
From my view point you have 3 choices. 1) Dlookup 2) a query & base the form
on it 3) VB code with a select case or if statement.

Dlookup syntax:

DLookup («expr», «domain», «criteria»)

the expr is the name of the field that holds your description, you can also
do math here if you want.

the domain is the table name

the criteria is the filter like "itemnumber = 3" would give everything that
has item number 3

also all 3 parts need to have " marks around them


Hopefully that helps and makes since.

Zach
 
P

pietlinden

I have a form that an item number can be entered.  I would like the item
number to be entered and the description to populate the item description..  I
have read that using a dlookup is a bad thing (not that I know how to code
that).

The item and descriptions are on an item master tblItemMaster.

why not just use a combobox for the ItemNumber and then show two
columns (Item Number and Item Description). then you can set the
widths to, say, "1";"0" (first column one inch wide, second column 0
inches wide). Then you can create an unbound textbox on your form
with the control source of Me.cboItemNumber.Column(1)

And you don't need one of those nasty lookup things.
 
?

.

hey, how do you include a text string in the lookup?
i tried this and get a syntax error
=DLookUp("[rate]","[taxes]","[taxname]=salestax1)
i tried it like this and the lookup returned #error
=DLookUp("[rate]","[taxes]","[taxname]=""salestax1")

also, what gets returned if the lookup finds more than one record in the
table meeting the same criteria???
 
J

John W. Vinson

hey, how do you include a text string in the lookup?
i tried this and get a syntax error
=DLookUp("[rate]","[taxes]","[taxname]=salestax1)
i tried it like this and the lookup returned #error
=DLookUp("[rate]","[taxes]","[taxname]=""salestax1")

Enclose the criterion in either single quotes or doublequotes. If you use the
latter, you must deal with the fact that you're doing so inside a string
already delimited by doublequotes; to insert a doublequote inside a string
delimited by doublequotes use a double doublequote (how's THAT for
doubletalk!?)

Either

=DLookUp("[rate]","[taxes]","[taxname]='salestax1'")

Spaced out for readability that's

=DLookUp("[rate]","[taxes]","[taxname]='salestax1' " )

or

=DLookUp("[rate]","[taxes]","[taxname]=""salestax1""")
also, what gets returned if the lookup finds more than one record in the
table meeting the same criteria???

The first one it comes to - basically, an arbitrary, unpredictable one of
however many match.
 
?

.

thanks, that works. i tried so many versions of the syntax my eyes were
starting to cross.



John W. Vinson said:
hey, how do you include a text string in the lookup?
i tried this and get a syntax error
=DLookUp("[rate]","[taxes]","[taxname]=salestax1)
i tried it like this and the lookup returned #error
=DLookUp("[rate]","[taxes]","[taxname]=""salestax1")

Enclose the criterion in either single quotes or doublequotes. If you use
the
latter, you must deal with the fact that you're doing so inside a string
already delimited by doublequotes; to insert a doublequote inside a string
delimited by doublequotes use a double doublequote (how's THAT for
doubletalk!?)

Either

=DLookUp("[rate]","[taxes]","[taxname]='salestax1'")

Spaced out for readability that's

=DLookUp("[rate]","[taxes]","[taxname]='salestax1' " )

or

=DLookUp("[rate]","[taxes]","[taxname]=""salestax1""")
also, what gets returned if the lookup finds more than one record in the
table meeting the same criteria???

The first one it comes to - basically, an arbitrary, unpredictable one of
however many match.
 
L

Larry Linson

Rpettis31 said:
I have a form that an item number can be entered. I would like the item
number to be entered and the description to populate the item description.
I
have read that using a dlookup is a bad thing (not that I know how to code
that).

The item and descriptions are on an item master tblItemMaster.

You did not say whether the Form is based on that table, or a Query based on
that Table, or on a different Table or Query. If you would clarify, with
some detail, what you have and what you are trying to accomplish, you may
get suggestions that will better solve the problem you face.

I'm concerned that your mention of DLookup may have led some responders down
the wrong path.

As Ross the Boss said, "The Devil's in the Details."

Larry Linson
Microsoft Office Access MVP
 
I

Iyana

hello. I need a someone to type too, so if your interested please type me
back. Thank you

. said:
hey, how do you include a text string in the lookup?
i tried this and get a syntax error
=DLookUp("[rate]","[taxes]","[taxname]=salestax1)
i tried it like this and the lookup returned #error
=DLookUp("[rate]","[taxes]","[taxname]=""salestax1")

also, what gets returned if the lookup finds more than one record in the
table meeting the same criteria???


ZigZagZak said:
There is nothing wrong with using dlookup. I use it on all of my
databases.
From my view point you have 3 choices. 1) Dlookup 2) a query & base the
form
on it 3) VB code with a select case or if statement.

Dlookup syntax:

DLookup («expr», «domain», «criteria»)

the expr is the name of the field that holds your description, you can
also
do math here if you want.

the domain is the table name

the criteria is the filter like "itemnumber = 3" would give everything
that
has item number 3

also all 3 parts need to have " marks around them


Hopefully that helps and makes since.

Zach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top