Referring to value in subform control

  • Thread starter Thread starter Renee Moffett
  • Start date Start date
R

Renee Moffett

Can someone help me find my mistake? The following code keeps prompting me
for
Forms]![frmZipToHomeChoices]![Form]![sbfrmMariesZipToHomeBookChoices]![direc
tory no]. I've verified the form and control names are accurate. I must
have something in the wrong order? I know "Forms" is for main forms and
"Form" is for subforms, but I'm stumped on why it dislikes this.

THANKS!

SELECT qryMariesZipToHomeBookChoices.[zip code],
qryMariesZipToHomeBookChoices.[directory no],
qryMariesZipToHomeBookChoices.MakeHome
FROM qryMariesZipToHomeBookChoices
WHERE (((qryMariesZipToHomeBookChoices.[zip
code])=[Forms]![frmZipToHomeChoices]![zip code]) AND
((qryMariesZipToHomeBookChoices.[directory
no])=[Forms]![frmZipToHomeChoices]![Form]![sbfrmMariesZipToHomeBookChoices]!
[directory no]) AND ((qryMariesZipToHomeBookChoices.MakeHome)=-1));
 
The ".Form" bit needs to follow the subform control name:
[Forms]![frmZipToHomeChoices]![sbfrmMariesZipToHomeBookChoices].[Form]![dire
ctory no]

It means: "Give me the form in the subform control."

BTW, you mention "code"? If this is opening a recordset in code, you may
need to concatenate the value from the subform into the SQL string:
strSQL = "SELECT ... WHERE ... [directoryno] = " & _
Forms!frmZipToHomeChoices!sbfrmMariesZipToHomeBookChoices.Form!directory no
& " ...

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

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

Renee Moffett .Moffett .com> said:
Can someone help me find my mistake? The following code keeps prompting me
Forms]![frmZipToHomeChoices]![Form]![sbfrmMariesZipToHomeBookChoices]![direc
tory no]. I've verified the form and control names are accurate. I must
have something in the wrong order? I know "Forms" is for main forms and
"Form" is for subforms, but I'm stumped on why it dislikes this.

THANKS!

SELECT qryMariesZipToHomeBookChoices.[zip code],
qryMariesZipToHomeBookChoices.[directory no],
qryMariesZipToHomeBookChoices.MakeHome
FROM qryMariesZipToHomeBookChoices
WHERE (((qryMariesZipToHomeBookChoices.[zip
code])=[Forms]![frmZipToHomeChoices]![zip code]) AND
((qryMariesZipToHomeBookChoices.[directory
no])=[Forms]![frmZipToHomeChoices]![Form]![sbfrmMariesZipToHomeBookChoices]!
[directory no]) AND ((qryMariesZipToHomeBookChoices.MakeHome)=-1));
 
Thanks Allen, that helped.

Renee

Allen Browne said:
The ".Form" bit needs to follow the subform control name:
[Forms]![frmZipToHomeChoices]![sbfrmMariesZipToHomeBookChoices].[Form]![dire
ctory no]

It means: "Give me the form in the subform control."

BTW, you mention "code"? If this is opening a recordset in code, you may
need to concatenate the value from the subform into the SQL string:
strSQL = "SELECT ... WHERE ... [directoryno] = " & _
Forms!frmZipToHomeChoices!sbfrmMariesZipToHomeBookChoices.Form!directory no
& " ...

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

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

Renee Moffett .Moffett .com> said:
Can someone help me find my mistake? The following code keeps prompting me
Forms]![frmZipToHomeChoices]![Form]![sbfrmMariesZipToHomeBookChoices]![direc
tory no]. I've verified the form and control names are accurate. I must
have something in the wrong order? I know "Forms" is for main forms and
"Form" is for subforms, but I'm stumped on why it dislikes this.

THANKS!

SELECT qryMariesZipToHomeBookChoices.[zip code],
qryMariesZipToHomeBookChoices.[directory no],
qryMariesZipToHomeBookChoices.MakeHome
FROM qryMariesZipToHomeBookChoices
WHERE (((qryMariesZipToHomeBookChoices.[zip
code])=[Forms]![frmZipToHomeChoices]![zip code]) AND
((qryMariesZipToHomeBookChoices.[directory
no])=[Forms]![frmZipToHomeChoices]![Form]![sbfrmMariesZipToHomeBookChoices]!
[directory no]) AND ((qryMariesZipToHomeBookChoices.MakeHome)=-1));
 
Back
Top