473,416 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Form/Subform

I'm stuck on something that seems should be easy and I need some help. My
main form has an option group with five options. My subform chooses from
different lists depending on which option is selected in the main form. I
thought all I had to do for the subform was create a query and set the
criteria equal to the option group value in the main form. No way, Jose!
When the form/subform opens, the option group value is not available to the
subform because the subfoem opens ahead of the main form. I can't have an
event in the main form set the query in the subform at data entry because
the form/subform needs to display existing records when the form/subform
opens. How can I set this up?

Thanks,

Steve
Nov 13 '05 #1
9 2720
PC Datasheet wrote:
I'm stuck on something that seems should be easy and I need some help. My
main form has an option group with five options. My subform chooses from
different lists depending on which option is selected in the main form. I
thought all I had to do for the subform was create a query and set the
criteria equal to the option group value in the main form. No way, Jose!
When the form/subform opens, the option group value is not available to the
subform because the subfoem opens ahead of the main form. I can't have an
event in the main form set the query in the subform at data entry because
the form/subform needs to display existing records when the form/subform
opens. How can I set this up?


There may be better ways to do this, but I run into this a lot. What I
do is set the subform query to either a specific criteria that matches,
but does not refer to the option group:

Select blah blah from Ooga booga Where MY_FIELD = 1

Where 1 is the default value of the option group.

Then, in the after update event of the option group I have something
like this:

Me.SubForm.Form.Recordsource = "Select blah blah from Ooga booga Where
MY_FIELD = " & me.OptionGroupValue

There might be another way around it, but if there is, I've gotten set
in my probably over-complicated ways...
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #2
Tim,

Thanks for responding!

I see where what you do will work for data entry but what do you do where
you have existing records in the database where the first record in the main
form's subform has records based on the option group value of 3 (rather than
1)? How do you get 3 from the main form to the subform when the subform is
opening before the main form has opened?

Steve
"Tim Marshall" <TI****@PurplePandaChasers.Moertherium> wrote in message
news:de**********@coranto.ucs.mun.ca...
PC Datasheet wrote:
I'm stuck on something that seems should be easy and I need some help. My
main form has an option group with five options. My subform chooses from
different lists depending on which option is selected in the main form. I
thought all I had to do for the subform was create a query and set the
criteria equal to the option group value in the main form. No way, Jose!
When the form/subform opens, the option group value is not available to
the subform because the subfoem opens ahead of the main form. I can't
have an event in the main form set the query in the subform at data entry
because the form/subform needs to display existing records when the
form/subform opens. How can I set this up?


There may be better ways to do this, but I run into this a lot. What I do
is set the subform query to either a specific criteria that matches, but
does not refer to the option group:

Select blah blah from Ooga booga Where MY_FIELD = 1

Where 1 is the default value of the option group.

Then, in the after update event of the option group I have something like
this:

Me.SubForm.Form.Recordsource = "Select blah blah from Ooga booga Where
MY_FIELD = " & me.OptionGroupValue

There might be another way around it, but if there is, I've gotten set in
my probably over-complicated ways...
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me

Nov 13 '05 #3
Initially set NO recordsource for the subform.
Assign the recordsource for the subform in the mainform's Activate event like:

Private Sub Form_Activate()
Me!MySubform.Form.Recordsource= "SQL or query here"
End sub

Arno R

"PC Datasheet" <no****@nospam.spam> schreef in bericht news:UY***************@newsread3.news.atl.earthlin k.net...
Tim,

Thanks for responding!

I see where what you do will work for data entry but what do you do where
you have existing records in the database where the first record in the main
form's subform has records based on the option group value of 3 (rather than
1)? How do you get 3 from the main form to the subform when the subform is
opening before the main form has opened?

Steve


"Tim Marshall" <TI****@PurplePandaChasers.Moertherium> wrote in message
news:de**********@coranto.ucs.mun.ca...
PC Datasheet wrote:
I'm stuck on something that seems should be easy and I need some help. My
main form has an option group with five options. My subform chooses from
different lists depending on which option is selected in the main form. I
thought all I had to do for the subform was create a query and set the
criteria equal to the option group value in the main form. No way, Jose!
When the form/subform opens, the option group value is not available to
the subform because the subfoem opens ahead of the main form. I can't
have an event in the main form set the query in the subform at data entry
because the form/subform needs to display existing records when the
form/subform opens. How can I set this up?


There may be better ways to do this, but I run into this a lot. What I do
is set the subform query to either a specific criteria that matches, but
does not refer to the option group:

Select blah blah from Ooga booga Where MY_FIELD = 1

Where 1 is the default value of the option group.

Then, in the after update event of the option group I have something like
this:

Me.SubForm.Form.Recordsource = "Select blah blah from Ooga booga Where
MY_FIELD = " & me.OptionGroupValue

There might be another way around it, but if there is, I've gotten set in
my probably over-complicated ways...
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me


Nov 13 '05 #4
Are you trying to set the subform's query string dynamically, such as in the
subform's onLoad event procedure?
If you create a saved query like:
SELECT foo from tblMyTable where some_field = forms!frmMain.frame1
then the subform should have no problem loading the correct records when the
form opens, becuase the form will requery the subform when it opens.
Maybe there is some reason you can't do this, but I didn't see it in your
question.

"PC Datasheet" <no****@nospam.spam> wrote in message
news:rh***************@newsread2.news.atl.earthlin k.net...
I'm stuck on something that seems should be easy and I need some help. My
main form has an option group with five options. My subform chooses from
different lists depending on which option is selected in the main form. I
thought all I had to do for the subform was create a query and set the
criteria equal to the option group value in the main form. No way, Jose!
When the form/subform opens, the option group value is not available to
the subform because the subfoem opens ahead of the main form. I can't have
an event in the main form set the query in the subform at data entry
because the form/subform needs to display existing records when the
form/subform opens. How can I set this up?

Thanks,

Steve

Nov 13 '05 #5
Thamks for responding, John!

This is he point where my question started. I initially did what you are
saying and Access threw up a parameter dialog asking for the value of
forms!frmMain.frame1because the subform opened ahead of the main form and
forms!frmMain.frame1 was not available to the subform's query criteria.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
Are you trying to set the subform's query string dynamically, such as in
the subform's onLoad event procedure?
If you create a saved query like:
SELECT foo from tblMyTable where some_field = forms!frmMain.frame1
then the subform should have no problem loading the correct records when
the form opens, becuase the form will requery the subform when it opens.
Maybe there is some reason you can't do this, but I didn't see it in your
question.

"PC Datasheet" <no****@nospam.spam> wrote in message
news:rh***************@newsread2.news.atl.earthlin k.net...
I'm stuck on something that seems should be easy and I need some help. My
main form has an option group with five options. My subform chooses from
different lists depending on which option is selected in the main form. I
thought all I had to do for the subform was create a query and set the
criteria equal to the option group value in the main form. No way, Jose!
When the form/subform opens, the option group value is not available to
the subform because the subfoem opens ahead of the main form. I can't
have an event in the main form set the query in the subform at data entry
because the form/subform needs to display existing records when the
form/subform opens. How can I set this up?

Thanks,

Steve


Nov 13 '05 #6
I do this all the time and it works fine. Just to make sure, I made a test
case to try it out again before my original post, and it worked fine.
Could you be spelling something wrong?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:VM***************@newsread1.news.atl.earthlin k.net...
Thamks for responding, John!

This is he point where my question started. I initially did what you are
saying and Access threw up a parameter dialog asking for the value of
forms!frmMain.frame1because the subform opened ahead of the main form and
forms!frmMain.frame1 was not available to the subform's query criteria.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
Are you trying to set the subform's query string dynamically, such as in
the subform's onLoad event procedure?
If you create a saved query like:
SELECT foo from tblMyTable where some_field = forms!frmMain.frame1
then the subform should have no problem loading the correct records when
the form opens, becuase the form will requery the subform when it opens.
Maybe there is some reason you can't do this, but I didn't see it in your
question.

"PC Datasheet" <no****@nospam.spam> wrote in message
news:rh***************@newsread2.news.atl.earthlin k.net...
I'm stuck on something that seems should be easy and I need some help.
My main form has an option group with five options. My subform chooses
from different lists depending on which option is selected in the main
form. I thought all I had to do for the subform was create a query and
set the criteria equal to the option group value in the main form. No
way, Jose! When the form/subform opens, the option group value is not
available to the subform because the subfoem opens ahead of the main
form. I can't have an event in the main form set the query in the
subform at data entry because the form/subform needs to display existing
records when the form/subform opens. How can I set this up?

Thanks,

Steve



Nov 13 '05 #7
Don't know if it makes a difference but the query in the subform is the
rowsource for a combobox not the recordsource for the subform.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
I do this all the time and it works fine. Just to make sure, I made a test
case to try it out again before my original post, and it worked fine.
Could you be spelling something wrong?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:VM***************@newsread1.news.atl.earthlin k.net...
Thamks for responding, John!

This is he point where my question started. I initially did what you are
saying and Access threw up a parameter dialog asking for the value of
forms!frmMain.frame1because the subform opened ahead of the main form and
forms!frmMain.frame1 was not available to the subform's query criteria.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
Are you trying to set the subform's query string dynamically, such as in
the subform's onLoad event procedure?
If you create a saved query like:
SELECT foo from tblMyTable where some_field = forms!frmMain.frame1
then the subform should have no problem loading the correct records when
the form opens, becuase the form will requery the subform when it opens.
Maybe there is some reason you can't do this, but I didn't see it in
your question.

"PC Datasheet" <no****@nospam.spam> wrote in message
news:rh***************@newsread2.news.atl.earthlin k.net...
I'm stuck on something that seems should be easy and I need some help.
My main form has an option group with five options. My subform chooses
from different lists depending on which option is selected in the main
form. I thought all I had to do for the subform was create a query and
set the criteria equal to the option group value in the main form. No
way, Jose! When the form/subform opens, the option group value is not
available to the subform because the subfoem opens ahead of the main
form. I can't have an event in the main form set the query in the
subform at data entry because the form/subform needs to display
existing records when the form/subform opens. How can I set this up?

Thanks,

Steve



Nov 13 '05 #8
I just tried that out too and it works just fine for me.
There must be some detail that you're not mentioning. Would you like me to
send you the db I made to test my answer?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:NM**************@newsread3.news.atl.earthlink .net...
Don't know if it makes a difference but the query in the subform is the
rowsource for a combobox not the recordsource for the subform.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
I do this all the time and it works fine. Just to make sure, I made a test
case to try it out again before my original post, and it worked fine.
Could you be spelling something wrong?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:VM***************@newsread1.news.atl.earthlin k.net...
Thamks for responding, John!

This is he point where my question started. I initially did what you are
saying and Access threw up a parameter dialog asking for the value of
forms!frmMain.frame1because the subform opened ahead of the main form
and forms!frmMain.frame1 was not available to the subform's query
criteria.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
Are you trying to set the subform's query string dynamically, such as
in the subform's onLoad event procedure?
If you create a saved query like:
SELECT foo from tblMyTable where some_field = forms!frmMain.frame1
then the subform should have no problem loading the correct records
when the form opens, becuase the form will requery the subform when it
opens.
Maybe there is some reason you can't do this, but I didn't see it in
your question.

"PC Datasheet" <no****@nospam.spam> wrote in message
news:rh***************@newsread2.news.atl.earthlin k.net...
> I'm stuck on something that seems should be easy and I need some help.
> My main form has an option group with five options. My subform chooses
> from different lists depending on which option is selected in the main
> form. I thought all I had to do for the subform was create a query and
> set the criteria equal to the option group value in the main form. No
> way, Jose! When the form/subform opens, the option group value is not
> available to the subform because the subfoem opens ahead of the main
> form. I can't have an event in the main form set the query in the
> subform at data entry because the form/subform needs to display
> existing records when the form/subform opens. How can I set this up?
>
> Thanks,
>
> Steve
>



Nov 13 '05 #9
Thanks, John, I would appreciate very much to be able to look at your test
DB. You can send it to re******@pcdatasheet.com.
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews1.newsguy.com...
I just tried that out too and it works just fine for me.
There must be some detail that you're not mentioning. Would you like me to
send you the db I made to test my answer?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:NM**************@newsread3.news.atl.earthlink .net...
Don't know if it makes a difference but the query in the subform is the
rowsource for a combobox not the recordsource for the subform.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in message
news:de*********@enews3.newsguy.com...
I do this all the time and it works fine. Just to make sure, I made a
test case to try it out again before my original post, and it worked
fine.
Could you be spelling something wrong?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:VM***************@newsread1.news.atl.earthlin k.net...
Thamks for responding, John!

This is he point where my question started. I initially did what you
are saying and Access threw up a parameter dialog asking for the value
of forms!frmMain.frame1because the subform opened ahead of the main
form and forms!frmMain.frame1 was not available to the subform's query
criteria.

Steve
"John Welch" <j+ohnw+elch@cal+central.com (remove +'s)> wrote in
message news:de*********@enews3.newsguy.com...
> Are you trying to set the subform's query string dynamically, such as
> in the subform's onLoad event procedure?
> If you create a saved query like:
> SELECT foo from tblMyTable where some_field = forms!frmMain.frame1
> then the subform should have no problem loading the correct records
> when the form opens, becuase the form will requery the subform when it
> opens.
> Maybe there is some reason you can't do this, but I didn't see it in
> your question.
>
> "PC Datasheet" <no****@nospam.spam> wrote in message
> news:rh***************@newsread2.news.atl.earthlin k.net...
>> I'm stuck on something that seems should be easy and I need some
>> help. My main form has an option group with five options. My subform
>> chooses from different lists depending on which option is selected in
>> the main form. I thought all I had to do for the subform was create a
>> query and set the criteria equal to the option group value in the
>> main form. No way, Jose! When the form/subform opens, the option
>> group value is not available to the subform because the subfoem opens
>> ahead of the main form. I can't have an event in the main form set
>> the query in the subform at data entry because the form/subform needs
>> to display existing records when the form/subform opens. How can I
>> set this up?
>>
>> Thanks,
>>
>> Steve
>>
>
>



Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
2
by: Claude | last post by:
Let' say we have an application for a production facility running 24/7 broken into 3 shifts 6-2,2-10,10-6 each production report date contains 3 shifts as above in each shift there can be from...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
12
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can...
14
by: Anja | last post by:
Hi everyone, I have a sub form that references a query to get the results. However, what I want to do is filter the results further based on a certain criteria. How can I tell the sub form to...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
6
NeoPa
by: NeoPa | last post by:
Introduction The first thing to understand about Sub-Forms is that, to add a form onto another form takes a special Subform control. This Subform control acts as a container for the form that you...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.