Query from a subform problem

P

polman

After over 16 Hours buzzing with a problem I give up. I need some
expert here (I think). Here it goes...
I need to run a query from a subform (it took me very long time to find
that this is the buzz...). The condition of this query is sited on a
combobox in that subform. So the SQL for this condition look like this:
Forms!ExamForm!ExamTypeCombo.Value (I need the current text value of
"ExamTypeCombo" combobox). Well, it seems that access does not
understand this, probably because, this combo box sited in a subform so
it prompts to enter a value on a dialogbox: Enter Value
Forms!ExamForm!ExamTypeCombo.Value.
Which is the teak here to tell access what I want (That is the value of
a combobox in a subform)? Either as a condition in SQL form and/or in
VBA code. (I apologize... I 'm a new in access)

PS. Of course the same code works fine when the subform (containing the
combobox) is opend on its own window.
 
A

Allen Browne

The subform is not open in its own right, i.e. you need to refer to it
through the main form.

If the main form is named Form1, you need:
[Forms].[Form1].[ExamForm].[Form].[ExamTypeCombo]

For an explanation, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html
 
P

polman

Allen thank you for your quick answer. Sorry to bother you and the
group again...
Of course, I had tried this too. It does not work either...
But, I have to admit that this problem appears only in one project (so
far).
In others (I also made some others to test this odd behavior) the
reference you made works fine.
Of course, if I cannot find the "bug" I have to quit this project for a
new one. But, you know, it took me so many hours of buzzling myself and
I thought it would be a good idea to ask some help.
The subform is not open in its own right, i.e. you need to refer to it
through the main form.

If the main form is named Form1, you need:
[Forms].[Form1].[ExamForm].[Form].[ExamTypeCombo]

For an explanation, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html

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

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

After over 16 Hours buzzing with a problem I give up. I need some
expert here (I think). Here it goes...
I need to run a query from a subform (it took me very long time to find
that this is the buzz...). The condition of this query is sited on a
combobox in that subform. So the SQL for this condition look like this:
Forms!ExamForm!ExamTypeCombo.Value (I need the current text value of
"ExamTypeCombo" combobox). Well, it seems that access does not
understand this, probably because, this combo box sited in a subform so
it prompts to enter a value on a dialogbox: Enter Value
Forms!ExamForm!ExamTypeCombo.Value.
Which is the teak here to tell access what I want (That is the value of
a combobox in a subform)? Either as a condition in SQL form and/or in
VBA code. (I apologize... I 'm a new in access)

PS. Of course the same code works fine when the subform (containing the
combobox) is opend on its own window.
 
A

Allen Browne

Perhaps the subform control has a Name that is not the same as the name of
the form loaded into it (i.e. its Name property is not the same as its
SourceObject property.)

Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
What's its Name?

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

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

Allen thank you for your quick answer. Sorry to bother you and the
group again...
Of course, I had tried this too. It does not work either...
But, I have to admit that this problem appears only in one project (so
far).
In others (I also made some others to test this odd behavior) the
reference you made works fine.
Of course, if I cannot find the "bug" I have to quit this project for a
new one. But, you know, it took me so many hours of buzzling myself and
I thought it would be a good idea to ask some help.
The subform is not open in its own right, i.e. you need to refer to it
through the main form.

If the main form is named Form1, you need:
[Forms].[Form1].[ExamForm].[Form].[ExamTypeCombo]

For an explanation, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html

After over 16 Hours buzzing with a problem I give up. I need some
expert here (I think). Here it goes...
I need to run a query from a subform (it took me very long time to find
that this is the buzz...). The condition of this query is sited on a
combobox in that subform. So the SQL for this condition look like this:
Forms!ExamForm!ExamTypeCombo.Value (I need the current text value of
"ExamTypeCombo" combobox). Well, it seems that access does not
understand this, probably because, this combo box sited in a subform so
it prompts to enter a value on a dialogbox: Enter Value
Forms!ExamForm!ExamTypeCombo.Value.
Which is the teak here to tell access what I want (That is the value of
a combobox in a subform)? Either as a condition in SQL form and/or in
VBA code. (I apologize... I 'm a new in access)

PS. Of course the same code works fine when the subform (containing the
combobox) is opend on its own window.
 
P

polman

Allen thank you for your time. I visit your site... just great!
YES!!! That was the problem!!!
Thank you so much! I now, remember that I had changed the name of the
form but I did knew that the name of the control is that I needed. Of
course now when I put the name of the control in the place of the name
of the form IT WORKS!
Thank you again.


Ï/Ç Allen Browne Ýãñáøå:
 

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