What's wrong with this?

T

Tom

Hi,

I'm trying to have a DLookup function where on the form after the user input
ContactName field the Company will populate automatically.

The table is Contactstbl with the fields FullName and company.

This is what I tried to do:

Private Sub ContactName_AfterUpdate()
Dim Comp As Variant
Comp = DLookup("[Company]", "Contactstbl", "[FullName] =" _
& Forms![MeetNCall]!ContactName)
Me.Company = Comp
End Sub


It does not work, any ideas?

TIA,

Tom
 
D

Douglas J. Steele

Assuming FullName is a text field, you need quotes around the value to which
you're comparing:

Comp = DLookup("[Company]", "Contactstbl", "[FullName] =""" _
& Forms![MeetNCall]!ContactName & """")

That's three double quotes in front, and four double quotes afterwards.
 
T

Tom

Thank you so much.
Douglas J. Steele said:
Assuming FullName is a text field, you need quotes around the value to
which you're comparing:

Comp = DLookup("[Company]", "Contactstbl", "[FullName] =""" _
& Forms![MeetNCall]!ContactName & """")

That's three double quotes in front, and four double quotes afterwards.


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Tom said:
Hi,

I'm trying to have a DLookup function where on the form after the user
input ContactName field the Company will populate automatically.

The table is Contactstbl with the fields FullName and company.

This is what I tried to do:

Private Sub ContactName_AfterUpdate()
Dim Comp As Variant
Comp = DLookup("[Company]", "Contactstbl", "[FullName] =" _
& Forms![MeetNCall]!ContactName)
Me.Company = Comp
End Sub


It does not work, any ideas?

TIA,

Tom
 

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