Auto Populating fields

K

kinlye

I'm trying to auto fill the district and Building Name based on the cc#
entered.

Here's the code:
Me.District = DLookup("[District]", "CostCenters", "[CCNum]=" &
Me.CostCenterNum)
Me.Building = DLookup("[BldgName]", "CostCenters", "[CCNum]=" &
Me.CostCenterNum)

It gives me a 3464 error.
I've tried a few things, but at this point, I'm running in circles.
Any help would be appreciated.
Let me know if I haven't given enough information.
J
 
O

Ofer Cohen

If the type of the CCNum field is string then try:

Me.District = DLookup("[District]", "CostCenters", "[CCNum]='" &
Me.CostCenterNum & "'")
Me.Building = DLookup("[BldgName]", "CostCenters", "[CCNum]='" &
Me.CostCenterNum & "'")

using criteria with number you can use it the way it was, with string you
need to add single quote, and date use #.
 

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