Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Surely This Is Simple?

Status
Not open for further replies.

Dannybe2

Programmer
Jan 31, 2001
136
GB
I'm trying to fill in a field from another field in a form in Microsoft Access, and it won't let me.

I'm using the following code:

Me.CompanyTelephoneNumber = DLookUp("CompanyTelephoneNumber", "Company Book", "Company = " & Me.Company.Value"

I get an error with the criteria which doesn't appear to be right. The helpful tooltip tells me the correct me.company.value as does the immediate window. Shouldn't it be "CompanyID = " & Me.Company.Value" ?
 
The table name might have to be in brackets [table_name] to distinguish it from fields "field_name".
 
Me.CompanyTelephoneNumber = DLookUp("[CompanyTelephoneNumber]", "Company Book", "[Company] = Company")

*Company* should be your Control Name

You can´t use the Me Keyword in Dlookup() Function...Only when you have the Recordset Open like in .FindFirst
Best Regards

---
JoaoTL
mail@jtl.co.pt
My MS Access Site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top