Unable to resolve runtime error 2465

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

Guest

MS Access 2000, Win XP
===================
Hi,

This is probably quite simple, but I'm totally missing it, and need some
fresh eyes to look at this.

I have a form with a combo-box control that is used to select a name. The
names and their phone numbers are stored in a table called 'tblPerson'.

I also have unbound text control to display the phone number of the person
selected in the combo-box.

I'm setting this in the AfterUpdate event of the combo-box, using a DLookup.
Here's the code:
============================================
Private Sub cboHCTeamCoordinatorID_AfterUpdate()

Dim varHCCoordinatorPhone As Variant
varHCCoordinatorPhone = DLookup([PersonPhoneNumber], "tblPerson",
"[PersonID] = " & Me.cboHCTeamCoordinatorID.Value)
Me.txtHCCoordinatorPhone = varHCCoordinatorPhone

End Sub
===============================================
This gives me run-time error 2465, with the following : MS Access can't find
the field '|' referred to in your expression.

I've used different combinations in the code:
1. Instead of assigning the value to a variant, I've tried to assign it
directly to the unbound textbox.

2. In the criteria of Dlookup, I've used "Me.cboHCTeamCoordinatorID" and
"Me.HCTeamCoordinatorID" (that's the field in the table where value is stored.

I've checked and re-checked the table and field names, and they are correct
(or, I'm really being dense, which is a possibility :).

Any help will be appreciated.

Thanks.

-Amit
 
Never mind. Figured it out.

DLookup("[PersonPhoneNumber]", ...)

Putting quotes around [PersonPhone Number] did it.

Thanks.

-Amit
 
If the name and the phone number are on the same table why do you use
dlookup, instead add to the combo source another field: phone number and in
the code of the after update you can write
Me.txtHCCoordinatorPhone = me.cboHCTeamCoordinatorID.column(1) ' it start
with 0 that resurve for the name

Or in the ControlSource Property of the Phone text box you can write
= me.cboHCTeamCoordinatorID.column(1)

So you wont need to write any code, it will refresh it self with every
selection.
 
Ofer said:
If the name and the phone number are on the same table why do you use
dlookup, instead add to the combo source another field: phone number and in
the code of the after update you can write
Me.txtHCCoordinatorPhone = me.cboHCTeamCoordinatorID.column(1) ' it start
with 0 that resurve for the name

Or in the ControlSource Property of the Phone text box you can write
= me.cboHCTeamCoordinatorID.column(1)

So you wont need to write any code, it will refresh it self with every
selection.

Ah, that's a better idea. Thanks!!!
I'll try this out right now.

-Amit
 

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

Similar Threads

Rin Time error 2465 5
Run-time error 2465 1
Error 2465; Can't Find Field 5
Erro 2465 11
How to fix Error 2465 8
error message 2465 4
Run-time error 2465 after database import 6
Update Combo Box 4

Back
Top