DLookup problem

T

Tony Williams

I have a database with two tables tblbusiness and tblindividual. I have a
form, frmregistration, with a control source qryregistration, a query
combining the two tables joined on txtbusinessname. On the form I have a
combobox control, cmbbusinessname, based on the table tblbusiness. Also on
my form is a tabcontrol with a control called txtaddress1. I want this to be
automatically completed from the field txtaddress1in the table tblbusiness.
I have used this Dlookup expression but the field doesn't show the data.
What am I doing wrong?
=DLookUp("[txtaddress1]","[tblBusiness]","[txtbusinessname]=Forms![frmregistration].[cmbbusinessname]")
Thanks
Tony
 
R

Rick Brandt

Tony said:
I have a database with two tables tblbusiness and tblindividual. I
have a form, frmregistration, with a control source qryregistration,
a query combining the two tables joined on txtbusinessname. On the
form I have a combobox control, cmbbusinessname, based on the table
tblbusiness. Also on my form is a tabcontrol with a control called
txtaddress1. I want this to be automatically completed from the field
txtaddress1in the table tblbusiness. I have used this Dlookup
expression but the field doesn't show the data. What am I doing wrong?
=DLookUp("[txtaddress1]","[tblBusiness]","[txtbusinessname]=Forms![frmregistration].[cmbbusinessname]")
Thanks
Tony

How many columns in cmbbusinessname? If more than one which is the bound
column?
 
E

EeOr

Hi Tony, this is similar to a dlookup that I use, i have replaced it with
your field names, give it a try.

=DLookUp("[txtaddress1]","tblbusiness","[txtbusinessname] = " &
[cmbbusinessname])

Jon
 
T

Tony Williams

Thanks Rick pointed me in the right direction! The control was bound to the
wrong column.
Cheers
Tony
Rick Brandt said:
Tony said:
I have a database with two tables tblbusiness and tblindividual. I
have a form, frmregistration, with a control source qryregistration,
a query combining the two tables joined on txtbusinessname. On the
form I have a combobox control, cmbbusinessname, based on the table
tblbusiness. Also on my form is a tabcontrol with a control called
txtaddress1. I want this to be automatically completed from the field
txtaddress1in the table tblbusiness. I have used this Dlookup
expression but the field doesn't show the data. What am I doing wrong?
=DLookUp("[txtaddress1]","[tblBusiness]","[txtbusinessname]=Forms![frmregistration].[cmbbusinessname]")
Thanks
Tony

How many columns in cmbbusinessname? If more than one which is the bound
column?
 
T

Tony Williams

Thanks Jon, my problem was the control was bound to the wrong column in the
combo box.
Cheers
Tony
EeOr said:
Hi Tony, this is similar to a dlookup that I use, i have replaced it with
your field names, give it a try.

=DLookUp("[txtaddress1]","tblbusiness","[txtbusinessname] = " &
[cmbbusinessname])

Jon


Tony Williams said:
I have a database with two tables tblbusiness and tblindividual. I have a
form, frmregistration, with a control source qryregistration, a query
combining the two tables joined on txtbusinessname. On the form I have a
combobox control, cmbbusinessname, based on the table tblbusiness. Also on
my form is a tabcontrol with a control called txtaddress1. I want this to
be automatically completed from the field txtaddress1in the table
tblbusiness.
I have used this Dlookup expression but the field doesn't show the data.
What am I doing wrong?
=DLookUp("[txtaddress1]","[tblBusiness]","[txtbusinessname]=Forms![frmregistration].[cmbbusinessname]")
Thanks
Tony
 
D

Dianna DeWolf

I also had problems with DLookup. I created a text box on my form with the following:

=DLookUp("TrainingDate","Employees Training Hours","EmployeeName = Form![EmployeeName] And [TrainingDescription] = 1")

Following is what I was searching for in my "Employees Training Hours" table:

"Training Date"
"EmployeeName" (that matched the name on my form)
"Training Description" that has an ID of 1

Try this:

=DLookup("txtaddress1", "Business", "txtbusinessname = Form![cmbbusinessname]")

I don't think you have to enter the form's name in your expression. I think that by just using Form! in your expression, Access assumes you're referring to
the form you're placing the expression in.

Does this make sense?



EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 

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