Error for using Dlookup function in Subform

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

Guest

Hi All,

I found some error in Dlookup function like this below.

A=DLookup("AggType", "Tbl_Agg",
"[AggID]=[Forms]![Frm_Main_Design]![Child]![AggType]")

It work fine when i run in access 2002 but i got this error when i run with
access 2003. and i try to change the word '[child]' to name of subform
'[Form_Sub_Design]!

it shows the error like this following.

runtime error '2001'
you canceled the previous operation

How can i solve this problem?

Thanks in advance
Gogzilla
 
Thanks for your reply. I try to use your syntax but it still shows the error.
This is my controlsourc
=DLookUp("AggType","Tbl_Agg","[AggID]=[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

and
=DLookUp("AggType","Tbl_Agg","[AggID]=" &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

it shows the error in its text "#Error"
Could you give me some reasons for this situation?Why?

Thanks

Gogzilla

Allen Browne said:
Yes, A2003 does not like the reference that way.

Try:
A=DLookup("AggType", "Tbl_Agg", "[AggID] = " &
[Forms]![Frm_Main_Design]![Form_Sub_Design].Form![AggType])

For an explanation of the ".Form" bit, see:
http://allenbrowne.com/casu-04.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gogzilla said:
Hi All,

I found some error in Dlookup function like this below.

A=DLookup("AggType", "Tbl_Agg",
"[AggID]=[Forms]![Frm_Main_Design]![Child]![AggType]")

It work fine when i run in access 2002 but i got this error when i run
with
access 2003. and i try to change the word '[child]' to name of subform
'[Form_Sub_Design]!

it shows the error like this following.

runtime error '2001'
you canceled the previous operation

How can i solve this problem?

Thanks in advance
Gogzilla
 
You do need to concatenate the value from the subform into the 3rd argument.

Presumably:
- the form is open, and
- there is a value in the AggType control in the subform.

If you open the table in design view, what type of field is AggID?
If it is Text (not Number), you need extra quotes:
=DLookUp("AggType","Tbl_Agg","[AggID] = """ &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType] & """")

What type of field is your AggType text box bound to? Is it the same type as
the AggID you are comparing it to?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gogzilla said:
Thanks for your reply. I try to use your syntax but it still shows the
error.
This is my controlsource
=DLookUp("AggType","Tbl_Agg","[AggID]=[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

and
=DLookUp("AggType","Tbl_Agg","[AggID]=" &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

it shows the error in its text "#Error"
Could you give me some reasons for this situation?Why?

Thanks

Gogzilla

Allen Browne said:
Yes, A2003 does not like the reference that way.

Try:
A=DLookup("AggType", "Tbl_Agg", "[AggID] = " &
[Forms]![Frm_Main_Design]![Form_Sub_Design].Form![AggType])

For an explanation of the ".Form" bit, see:
http://allenbrowne.com/casu-04.html


Gogzilla said:
Hi All,

I found some error in Dlookup function like this below.

A=DLookup("AggType", "Tbl_Agg",
"[AggID]=[Forms]![Frm_Main_Design]![Child]![AggType]")

It work fine when i run in access 2002 but i got this error when i run
with
access 2003. and i try to change the word '[child]' to name of subform
'[Form_Sub_Design]!

it shows the error like this following.

runtime error '2001'
you canceled the previous operation

How can i solve this problem?

Thanks in advance
Gogzilla
 
Hi Browne,

I already try to use your syntax and check type of AGGID and AggType are
'text'

I still found error like this

Run-time error '2465'
Microsoft Office Access cna't find the field 'Frm_Sub_Design'referred to in
your expression

'Frm_Sub_Design' is the name of subform


Thanks
Gogzilla


Allen Browne said:
You do need to concatenate the value from the subform into the 3rd argument.

Presumably:
- the form is open, and
- there is a value in the AggType control in the subform.

If you open the table in design view, what type of field is AggID?
If it is Text (not Number), you need extra quotes:
=DLookUp("AggType","Tbl_Agg","[AggID] = """ &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType] & """")

What type of field is your AggType text box bound to? Is it the same type as
the AggID you are comparing it to?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gogzilla said:
Thanks for your reply. I try to use your syntax but it still shows the
error.
This is my controlsource
=DLookUp("AggType","Tbl_Agg","[AggID]=[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

and
=DLookUp("AggType","Tbl_Agg","[AggID]=" &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

it shows the error in its text "#Error"
Could you give me some reasons for this situation?Why?

Thanks

Gogzilla

Allen Browne said:
Yes, A2003 does not like the reference that way.

Try:
A=DLookup("AggType", "Tbl_Agg", "[AggID] = " &
[Forms]![Frm_Main_Design]![Form_Sub_Design].Form![AggType])

For an explanation of the ".Form" bit, see:
http://allenbrowne.com/casu-04.html


Hi All,

I found some error in Dlookup function like this below.

A=DLookup("AggType", "Tbl_Agg",
"[AggID]=[Forms]![Frm_Main_Design]![Child]![AggType]")

It work fine when i run in access 2002 but i got this error when i run
with
access 2003. and i try to change the word '[child]' to name of subform
'[Form_Sub_Design]!

it shows the error like this following.

runtime error '2001'
you canceled the previous operation

How can i solve this problem?

Thanks in advance
Gogzilla
 
Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
On the Other tab of the Properties box, what is the Name of the control?

Its Name can be different from the name of the form that gets loaded into
the control (its SourceObject).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Gogzilla said:
Hi Browne,

I already try to use your syntax and check type of AGGID and AggType are
'text'

I still found error like this

Run-time error '2465'
Microsoft Office Access cna't find the field 'Frm_Sub_Design'referred to
in
your expression

'Frm_Sub_Design' is the name of subform


Thanks
Gogzilla


Allen Browne said:
You do need to concatenate the value from the subform into the 3rd
argument.

Presumably:
- the form is open, and
- there is a value in the AggType control in the subform.

If you open the table in design view, what type of field is AggID?
If it is Text (not Number), you need extra quotes:
=DLookUp("AggType","Tbl_Agg","[AggID] = """ &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType] & """")

What type of field is your AggType text box bound to? Is it the same type
as
the AggID you are comparing it to?


Gogzilla said:
Thanks for your reply. I try to use your syntax but it still shows the
error.
This is my controlsource
=DLookUp("AggType","Tbl_Agg","[AggID]=[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

and
=DLookUp("AggType","Tbl_Agg","[AggID]=" &
[Forms]![Frm_Main_Design]![Frm_Sub_Design].Form![AggType]")

it shows the error in its text "#Error"
Could you give me some reasons for this situation?Why?

Thanks

Gogzilla

:

Yes, A2003 does not like the reference that way.

Try:
A=DLookup("AggType", "Tbl_Agg", "[AggID] = " &
[Forms]![Frm_Main_Design]![Form_Sub_Design].Form![AggType])

For an explanation of the ".Form" bit, see:
http://allenbrowne.com/casu-04.html


Hi All,

I found some error in Dlookup function like this below.

A=DLookup("AggType", "Tbl_Agg",
"[AggID]=[Forms]![Frm_Main_Design]![Child]![AggType]")

It work fine when i run in access 2002 but i got this error when i
run
with
access 2003. and i try to change the word '[child]' to name of
subform
'[Form_Sub_Design]!

it shows the error like this following.

runtime error '2001'
you canceled the previous operation

How can i solve this problem?

Thanks in advance
Gogzilla
 
Thank you very much for your advise. the actual name of subform is Child as
the first name in syntax. it can work now..

Gogzilla
 

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

Back
Top