Yet another DLookup problem!

T

Tony Williams

I thought I'd got the hang of DLookup but just recently I cannot get any of
them to work, so frustrating when I think I'm following convention.
Anyway I have a form (frmmain) on which is a subform (frmcomplaint) The
frmcomplaint has a control txtauthto (which has a control source
=[cmbemployee].[column](1)) I want to check the value of txtauthto against a
table tblindividual and find the value of a field txtsurname where the value
of another field txtmemnumber =thevalue of txtauthto on my form.
Here's my Dlookup:
=DLookUp("[txtsurname]","[
tblindividual]","[txtmemnumber]=Forms!frmmain!frmcomplaint.Form![txtauthto]")

But I get#Error. Where am I going wrong?
Thanks
Tony
 
R

RonaldoOneNil

Your variable needs to be outside the double quotes and enclosed by single
quotes if its text.
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]='" &
Forms!frmmain!frmcomplaint.Form![txtauthto] & "'")
 
T

Tony Williams

Thanks for that but now I get #Name?
Any ideas?
Tony

RonaldoOneNil said:
Your variable needs to be outside the double quotes and enclosed by single
quotes if its text.
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]='" &
Forms!frmmain!frmcomplaint.Form![txtauthto] & "'")

Tony Williams said:
I thought I'd got the hang of DLookup but just recently I cannot get any of
them to work, so frustrating when I think I'm following convention.
Anyway I have a form (frmmain) on which is a subform (frmcomplaint) The
frmcomplaint has a control txtauthto (which has a control source
=[cmbemployee].[column](1)) I want to check the value of txtauthto against a
table tblindividual and find the value of a field txtsurname where the value
of another field txtmemnumber =thevalue of txtauthto on my form.
Here's my Dlookup:
=DLookUp("[txtsurname]","[
tblindividual]","[txtmemnumber]=Forms!frmmain!frmcomplaint.Form![txtauthto]")

But I get#Error. Where am I going wrong?
Thanks
Tony
 
R

RonaldoOneNil

Are txtmemnumber and txtauthto both text ?
If not, you do not need to enclose in single quotes
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]=" &
Forms!frmmain!frmcomplaint.Form![txtauthto])

Tony Williams said:
Thanks for that but now I get #Name?
Any ideas?
Tony

RonaldoOneNil said:
Your variable needs to be outside the double quotes and enclosed by single
quotes if its text.
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]='" &
Forms!frmmain!frmcomplaint.Form![txtauthto] & "'")

Tony Williams said:
I thought I'd got the hang of DLookup but just recently I cannot get any of
them to work, so frustrating when I think I'm following convention.
Anyway I have a form (frmmain) on which is a subform (frmcomplaint) The
frmcomplaint has a control txtauthto (which has a control source
=[cmbemployee].[column](1)) I want to check the value of txtauthto against a
table tblindividual and find the value of a field txtsurname where the value
of another field txtmemnumber =thevalue of txtauthto on my form.
Here's my Dlookup:
=DLookUp("[txtsurname]","[
tblindividual]","[txtmemnumber]=Forms!frmmain!frmcomplaint.Form![txtauthto]")

But I get#Error. Where am I going wrong?
Thanks
Tony
 
T

Tony Williams

They're both numbers
Tony

RonaldoOneNil said:
Are txtmemnumber and txtauthto both text ?
If not, you do not need to enclose in single quotes
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]=" &
Forms!frmmain!frmcomplaint.Form![txtauthto])

Tony Williams said:
Thanks for that but now I get #Name?
Any ideas?
Tony

RonaldoOneNil said:
Your variable needs to be outside the double quotes and enclosed by single
quotes if its text.
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]='" &
Forms!frmmain!frmcomplaint.Form![txtauthto] & "'")

:

I thought I'd got the hang of DLookup but just recently I cannot get any of
them to work, so frustrating when I think I'm following convention.
Anyway I have a form (frmmain) on which is a subform (frmcomplaint) The
frmcomplaint has a control txtauthto (which has a control source
=[cmbemployee].[column](1)) I want to check the value of txtauthto against a
table tblindividual and find the value of a field txtsurname where the value
of another field txtmemnumber =thevalue of txtauthto on my form.
Here's my Dlookup:
=DLookUp("[txtsurname]","[
tblindividual]","[txtmemnumber]=Forms!frmmain!frmcomplaint.Form![txtauthto]")

But I get#Error. Where am I going wrong?
Thanks
Tony
 
T

Tony Williams

I deserve a good kicking!!!!! Found the problem it was a spelling mistake the
field txtauthto was infact txauthto note the missing 2nd "t"
Sorry Ronaldo!!!
Thanks foryour help anyway
Sorry if I wasted your tme
Tony

Tony Williams said:
They're both numbers
Tony

RonaldoOneNil said:
Are txtmemnumber and txtauthto both text ?
If not, you do not need to enclose in single quotes
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]=" &
Forms!frmmain!frmcomplaint.Form![txtauthto])

Tony Williams said:
Thanks for that but now I get #Name?
Any ideas?
Tony

:

Your variable needs to be outside the double quotes and enclosed by single
quotes if its text.
=DLookUp("[txtsurname]","[tblindividual]","[txtmemnumber]='" &
Forms!frmmain!frmcomplaint.Form![txtauthto] & "'")

:

I thought I'd got the hang of DLookup but just recently I cannot get any of
them to work, so frustrating when I think I'm following convention.
Anyway I have a form (frmmain) on which is a subform (frmcomplaint) The
frmcomplaint has a control txtauthto (which has a control source
=[cmbemployee].[column](1)) I want to check the value of txtauthto against a
table tblindividual and find the value of a field txtsurname where the value
of another field txtmemnumber =thevalue of txtauthto on my form.
Here's my Dlookup:
=DLookUp("[txtsurname]","[
tblindividual]","[txtmemnumber]=Forms!frmmain!frmcomplaint.Form![txtauthto]")

But I get#Error. Where am I going wrong?
Thanks
Tony
 

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


Top