dlookup in subform not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I have a subform with employeID, names and other informations. I have
created a lookup function so that the name appears automatically when I
enter the EmployeeID.
This dlookup function works perfectly in my subform alone.

here is the code in the textbox' control source
=DLookUp("Nom";"TravailSaisie";"[Employé]=" & [Forms]![Travail1]![Employé])

(sorry for the names in french... Nom=Name, Travail means work,job, Employé
=Employee, TravailSaisie is the name of the query I used)

In the main form, the subform is linked by a date field. Dlookup no longer
works when I open the main form, in each text box, I get #Name?

What can I do to make this work?

Thanks a lot

Louis Pat
 
Your dlook up seperate the parts with ; and not ,
Try this
=DLookUp("Nom","TravailSaisie","[Employé]=" & [Forms]![Travail1]![Employé])

If the Employé is string field type then it should be
=DLookUp("Nom","TravailSaisie","[Employé]='" & [Forms]![Travail1]![Employé]
& "'")

Just in case it still gives you name, while the form is running, open the
immidiate form, (Ctrl+G), type the dlookup string, if it has any problem with
it, it will display the problem
 
Thanks for replying, but that didn't work

I tried your way before, with , instead of ; but Access was telling me that
the syntax was invalid. It worked perfectly with the ; instead but only in my
subform (if I open it separately). I still get #Name? in my main form (no
errors though)

Could you elaborate a little more on the hint you gave me to display the
problem. I 'd like to know how does it work. When I press ctrl g, where do I
ahve to type the dlookup? it only opens visualbasic, and i see my code as it
I always do. -> What does immediate do?

Thanks a lot

louis Pat
 
The code screen you can see split into two parts, the buttom one is the
immidiate window.
Type in it the dlookup, with a question mark infront of it.
?dlookup .....

remember the form has to run
 
HI!

My subform is named Travail (work in french) and my main form is named
Température for the moment. (I'll find a better name later...)

And I work in access 2000

thanks !
Gina Whipp said:
What is the name of the Main Form and what is the name of the Subform?


LouisPat said:
Hi!

I have a subform with employeID, names and other informations. I have
created a lookup function so that the name appears automatically when I
enter the EmployeeID.
This dlookup function works perfectly in my subform alone.

here is the code in the textbox' control source
=DLookUp("Nom";"TravailSaisie";"[Employé]=" &
[Forms]![Travail1]![Employé])

(sorry for the names in french... Nom=Name, Travail means work,job,
Employé
=Employee, TravailSaisie is the name of the query I used)

In the main form, the subform is linked by a date field. Dlookup no longer
works when I open the main form, in each text box, I get #Name?

What can I do to make this work?

Thanks a lot

Louis Pat
 
Louis Pat,

Try it like this...
=DLookUp("Nom";"TravailSaisie";"[Employé]=" & [Employé])

This assumes that you are referencing the same form for the Employé as
the DLookup function is on. The problem has arisen because the Travail
form is not open, it is just being displayed through the medium of the
subform control on the main form, so you can't refer to it in the
expression.
 
So the below is on the Subform and references the Main form? (Which looks
good!)
=DLookUp("Nom";"TravailSaisie";"[Employé]=" & [Forms]![Travail1]![Employé])

But IF the text field is on the Main Form and references the Subform, it
should be:
=[SubformName].Form![FieldName]

IF the text fields are references the same form it's on, it should be:
=[FieldName]

Hope that helps!

LouisPat said:
HI!

My subform is named Travail (work in french) and my main form is named
Température for the moment. (I'll find a better name later...)

And I work in access 2000

thanks !
Gina Whipp said:
What is the name of the Main Form and what is the name of the Subform?


LouisPat said:
Hi!

I have a subform with employeID, names and other informations. I have
created a lookup function so that the name appears automatically when
I
enter the EmployeeID.
This dlookup function works perfectly in my subform alone.

here is the code in the textbox' control source
=DLookUp("Nom";"TravailSaisie";"[Employé]=" &
[Forms]![Travail1]![Employé])

(sorry for the names in french... Nom=Name, Travail means work,job,
Employé
=Employee, TravailSaisie is the name of the query I used)

In the main form, the subform is linked by a date field. Dlookup no
longer
works when I open the main form, in each text box, I get #Name?

What can I do to make this work?

Thanks a lot

Louis Pat
 
Thanks Steve!

It worked perfectly !

You MVPS really rock

Thanks again

LouisPat

Steve Schapel said:
Louis Pat,

Try it like this...
=DLookUp("Nom";"TravailSaisie";"[Employé]=" & [Employé])

This assumes that you are referencing the same form for the Employé as
the DLookup function is on. The problem has arisen because the Travail
form is not open, it is just being displayed through the medium of the
subform control on the main form, so you can't refer to it in the
expression.

--
Steve Schapel, Microsoft Access MVP
Hi!

I have a subform with employeID, names and other informations. I have
created a lookup function so that the name appears automatically when I
enter the EmployeeID.
This dlookup function works perfectly in my subform alone.

here is the code in the textbox' control source
=DLookUp("Nom";"TravailSaisie";"[Employé]=" & [Forms]![Travail1]![Employé])

(sorry for the names in french... Nom=Name, Travail means work,job, Employé
=Employee, TravailSaisie is the name of the query I used)

In the main form, the subform is linked by a date field. Dlookup no longer
works when I open the main form, in each text box, I get #Name?

What can I do to make this work?

Thanks a lot

Louis Pat
 
Back
Top