DLookup Syntax Error

A

Adam

Hi,

in a form, I want a textbox to return a value based upon a previous
selection in a combo box. After I finally managed to write a function that
won't give me an invalid syntax error warning, the function just isn't
working.
I've tried to make a query, but I just get the message: Syntax error
(missing operator) in query expression '[Klasifikacija.ID] ='

I have two tables: [Akti] and [Klasifikacija]. The table [Akti] contains an
inventory listing, while the table [Klasifikacija] contains the
classification system. I've set a relationship between both tables using the
[ID] field (auto number).
Now, I have a form [Novi akt] that is based on an [Akti] table, and on that
form I have a combo box [OpisKlasifikacija] that I use to classify every item
from the inventory.
The table [Klafisikacija] has three fileds: [ID], [Klasa] and
[OpisKlasifikacija]. [ID] is an auto number, [Klasa] is a key that represents
every class in my classification system and [OpisKlasifikacija] is a
description of each class.
I want to have a textbox that will show the value from the [Klasa] field
from the [Klasifikacija] table when I assign the class to each inverntory
item using my combo box whit the description of that class.

Oh, yes, I've used a few expressions, but none of them worked, the last two
were:
=DLookUp("[Klasa]" ; "[Klasifikacija]","[ID] =" Forms![Novi akt]!ID)
=DLookup("[Klasa]", "[Klasifikacija]", "[Klasifikacija.ID]=" & Forms![Novi
akt]!ID)

Thank you for any likely solutions
 
M

Marshall Barton

Adam said:
in a form, I want a textbox to return a value based upon a previous
selection in a combo box. After I finally managed to write a function that
won't give me an invalid syntax error warning, the function just isn't
working.
I've tried to make a query, but I just get the message: Syntax error
(missing operator) in query expression '[Klasifikacija.ID] ='

I have two tables: [Akti] and [Klasifikacija]. The table [Akti] contains an
inventory listing, while the table [Klasifikacija] contains the
classification system. I've set a relationship between both tables using the
[ID] field (auto number).
Now, I have a form [Novi akt] that is based on an [Akti] table, and on that
form I have a combo box [OpisKlasifikacija] that I use to classify every item
from the inventory.
The table [Klafisikacija] has three fileds: [ID], [Klasa] and
[OpisKlasifikacija]. [ID] is an auto number, [Klasa] is a key that represents
every class in my classification system and [OpisKlasifikacija] is a
description of each class.
I want to have a textbox that will show the value from the [Klasa] field
from the [Klasifikacija] table when I assign the class to each inverntory
item using my combo box whit the description of that class.

Oh, yes, I've used a few expressions, but none of them worked, the last two
were:
=DLookUp("[Klasa]" ; "[Klasifikacija]","[ID] =" Forms![Novi akt]!ID)
=DLookup("[Klasa]", "[Klasifikacija]", "[Klasifikacija.ID]=" & Forms![Novi
akt]!ID)


Try using:

=DLookup("Klasa", "Klasifikacija", "ID=" & Forms![Novi
akt]!ID)
 
M

Mike Painter

Adam said:
Hi,

in a form, I want a textbox to return a value based upon a previous
selection in a combo box. After I finally managed to write a function
that won't give me an invalid syntax error warning, the function just
isn't working.
I've tried to make a query, but I just get the message: Syntax error
(missing operator) in query expression '[Klasifikacija.ID] ='

I have two tables: [Akti] and [Klasifikacija]. The table [Akti]
contains an inventory listing, while the table [Klasifikacija]
contains the classification system. I've set a relationship between
both tables using the [ID] field (auto number).
Now, I have a form [Novi akt] that is based on an [Akti] table, and
on that form I have a combo box [OpisKlasifikacija] that I use to
classify every item from the inventory.
The table [Klafisikacija] has three fileds: [ID], [Klasa] and
[OpisKlasifikacija]. [ID] is an auto number, [Klasa] is a key that
represents every class in my classification system and
[OpisKlasifikacija] is a description of each class.
I want to have a textbox that will show the value from the [Klasa]
field from the [Klasifikacija] table when I assign the class to each
inverntory item using my combo box whit the description of that class.

Oh, yes, I've used a few expressions, but none of them worked, the
last two were:
=DLookUp("[Klasa]" ; "[Klasifikacija]","[ID] =" Forms![Novi akt]!ID)
=DLookup("[Klasa]", "[Klasifikacija]", "[Klasifikacija.ID]=" &
Forms![Novi akt]!ID)

Thank you for any likely solutions

If ther tables are related properly then there is no need to lookup
anything.
Base your form on a query with that relationship and when you select the ID,
the Klasifikacija will show automatically.
 
D

DeZZar

your DLookup expression should work if expressed like:

a) If using VB to write the expression:
=DLookup("[FieldNameInTable]","TableName", "[FieldNameInTable]=" & "'"
& Forms!FormName!FormField & "'")

b) Or if binding a field to the expression
=DLookup("[Field]","TableName", "[FieldNameInTable]=Forms!FormName!
FormField")
 

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

Similar Threads

DLookUp syntax 9
DLookup Help 4
DLookup Syntex error it is killing me 7
dlookup formula in Form 5
dlookup 3
Another DLOOKUP question 2
DLookup Issue 9
DLookup? 1

Top