What's wrong with this?

  • Thread starter Thread starter Tom
  • Start date Start date
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
 
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.
 
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
 
Back
Top