Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Help with expressions?

Author  Topic 

MikeB
Constraint Violating Yak Guru

387 Posts

Posted - 2002-07-10 : 14:22:35
I have a table, PersonnelInformation where I have 2 fields, Name, Title. I have a form with a combo box and an edit box. When the user selects a name on the combo box. I want the title to show up in the edit box. I tried the following expression but it does not work:


=[EmployeeName].[OnChange]=DLookUp("[PersonnelInformationTable.Title]","PersonnelInformationTable","[[PersonnelInformationTable.Name] =" & [Forms]![EmployeesFrm]![EmployeeName])


This expression is attached to the edit box.

I have also tried the following VBA method:

Private Sub EmployeeName_Change()
Dim Title As String
Title = DLookup("[PersonnelInformationTable.Title]", "PersonnelInformationTable", "[PersonnelInformationTable.Name] = " & Forms!EmployeesFrm!EmployeeName)
Forms!EmployeesFrm!EmployeeTitle = Title
End Sub


What Am I doing wrong, and how can I accomplish this. I am now just learning access.

Mike B



Edited by - MikeB on 07/10/2002 14:34:33

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-10 : 14:42:02
I think you had one too many square brackets in your expression, see if this works:

=[EmployeeName].[OnChange]=DLookUp("[PersonnelInformationTable.Title]","PersonnelInformationTable","[PersonnelInformationTable.Name] =" & [Forms]![EmployeesFrm]![EmployeeName])

Take a look at this site, they have an excellent section on MS Access:

http://www.mvps.org/

Go to Top of Page
   

- Advertisement -