dlookup

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

Guest

Its been years since I've worked in Access and now I find myself thrown back
into it. I'm fustrated because I "seem" to remember that I could do things
but find that I don't remember exactly how to get it done.

I have a form (frmInvoiceComplete) attached to the table Invoices. In the
form I have a blank field that I would like to display the full country name
from another table Country. The table Invoices has the field "CountryCode"
as does the Country table. I've tried to use the DLookup function but seem
to have a problem getting it to work.

=DLookUp("[CountryName]","tblCountry","[CountryCode] =
Form![frmInvoiceComplete]!CountryCode")

Can you help?

I want it to return the field CountryName from the Country table
 
Try this

=DLookUp("[CountryName]","tblCountry","[CountryCode] = " &
Forms![frmInvoiceComplete]!CountryCode )

Or, if the country code field type is text use
=DLookUp("[CountryName]","tblCountry","[CountryCode] = '" &
Forms![frmInvoiceComplete]!CountryCode & "'")

=================================
In your dlookup, it should be written forms and not form.
 
Its been years since I've worked in Access and now I find myself thrown back
into it. I'm fustrated because I "seem" to remember that I could do things
but find that I don't remember exactly how to get it done.

I have a form (frmInvoiceComplete) attached to the table Invoices. In the
form I have a blank field that I would like to display the full country name
from another table Country. The table Invoices has the field "CountryCode"
as does the Country table. I've tried to use the DLookup function but seem
to have a problem getting it to work.

=DLookUp("[CountryName]","tblCountry","[CountryCode] =
Form![frmInvoiceComplete]!CountryCode")

Can you help?

I want it to return the field CountryName from the Country table


If this code is placed on the "frmInvoiceComplete" form you can
substitute the Me! keyword for "forms!frmInvoiceComplete".

What is the datatype of the [CountryCode] field?
If it is a Number datatype:

=DLookUp("[CountryName]","tblCountry","[CountryCode] = " &
Me![CountryCode])

If it is Text datatype:

=DLookUp("[CountryName]","tblCountry","[CountryCode] = '" &
Me![CountryCode] & "'")
 
Thanks, but not quite. It's soooooo close. I no longer have an error
message but it displays the first country listed in the Country table and not
the name of the country that matches up with the CountryCode!

What am I missing?

Ofer Cohen said:
Try this

=DLookUp("[CountryName]","tblCountry","[CountryCode] = " &
Forms![frmInvoiceComplete]!CountryCode )

Or, if the country code field type is text use
=DLookUp("[CountryName]","tblCountry","[CountryCode] = '" &
Forms![frmInvoiceComplete]!CountryCode & "'")

=================================
In your dlookup, it should be written forms and not form.

--
Good Luck
BS"D


BJackMom said:
Its been years since I've worked in Access and now I find myself thrown back
into it. I'm fustrated because I "seem" to remember that I could do things
but find that I don't remember exactly how to get it done.

I have a form (frmInvoiceComplete) attached to the table Invoices. In the
form I have a blank field that I would like to display the full country name
from another table Country. The table Invoices has the field "CountryCode"
as does the Country table. I've tried to use the DLookup function but seem
to have a problem getting it to work.

=DLookUp("[CountryName]","tblCountry","[CountryCode] =
Form![frmInvoiceComplete]!CountryCode")

Can you help?

I want it to return the field CountryName from the Country table
 
Can you post the Dlookup you are using?

Check again if you are passing the right value to the where condition in the
Dlookup statement.

--
Good Luck
BS"D


BJackMom said:
Thanks, but not quite. It's soooooo close. I no longer have an error
message but it displays the first country listed in the Country table and not
the name of the country that matches up with the CountryCode!

What am I missing?

Ofer Cohen said:
Try this

=DLookUp("[CountryName]","tblCountry","[CountryCode] = " &
Forms![frmInvoiceComplete]!CountryCode )

Or, if the country code field type is text use
=DLookUp("[CountryName]","tblCountry","[CountryCode] = '" &
Forms![frmInvoiceComplete]!CountryCode & "'")

=================================
In your dlookup, it should be written forms and not form.

--
Good Luck
BS"D


BJackMom said:
Its been years since I've worked in Access and now I find myself thrown back
into it. I'm fustrated because I "seem" to remember that I could do things
but find that I don't remember exactly how to get it done.

I have a form (frmInvoiceComplete) attached to the table Invoices. In the
form I have a blank field that I would like to display the full country name
from another table Country. The table Invoices has the field "CountryCode"
as does the Country table. I've tried to use the DLookup function but seem
to have a problem getting it to work.

=DLookUp("[CountryName]","tblCountry","[CountryCode] =
Form![frmInvoiceComplete]!CountryCode")

Can you help?

I want it to return the field CountryName from the Country table
 
=DLookUp("[CountryName]","tblCountry","[CountryCode] = '" &
Forms![frmInvoiceComplete]!CountryCode & "'")


Ofer Cohen said:
Can you post the Dlookup you are using?

Check again if you are passing the right value to the where condition in the
Dlookup statement.

--
Good Luck
BS"D


BJackMom said:
Thanks, but not quite. It's soooooo close. I no longer have an error
message but it displays the first country listed in the Country table and not
the name of the country that matches up with the CountryCode!

What am I missing?

Ofer Cohen said:
Try this

=DLookUp("[CountryName]","tblCountry","[CountryCode] = " &
Forms![frmInvoiceComplete]!CountryCode )

Or, if the country code field type is text use
=DLookUp("[CountryName]","tblCountry","[CountryCode] = '" &
Forms![frmInvoiceComplete]!CountryCode & "'")

=================================
In your dlookup, it should be written forms and not form.

--
Good Luck
BS"D


:

Its been years since I've worked in Access and now I find myself thrown back
into it. I'm fustrated because I "seem" to remember that I could do things
but find that I don't remember exactly how to get it done.

I have a form (frmInvoiceComplete) attached to the table Invoices. In the
form I have a blank field that I would like to display the full country name
from another table Country. The table Invoices has the field "CountryCode"
as does the Country table. I've tried to use the DLookup function but seem
to have a problem getting it to work.

=DLookUp("[CountryName]","tblCountry","[CountryCode] =
Form![frmInvoiceComplete]!CountryCode")

Can you help?

I want it to return the field CountryName from the Country table
 
Back
Top