retrieve sub form button

G

Guest

i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.

Please any suggestions and/or discussions are welcome.
 
M

Marshall Barton

scottjr said:
i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
G

Guest

Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

Marshall Barton said:
scottjr said:
i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
M

Marshall Barton

I don't understand. The code I posted will open some other
form (based on the "sub table") to the same ID as the
currently selected record in the members form. What about
this don't you like?

Actually, the usual approach to this kind of thing is to use
a subform instead of opening another form. Have you
investigated this scenario and rejected it? If so, why?

The only other interpretation I can put to your question is
that you want to open 10(?) copies of the other form at the
same time. This doesn't make a lot of sense to me because
it would make your screen so cluttered you wouldn't be able
to see anything useful. If this is what you really want to
do, be advised that this is a fairly advanced topic that
requires a significant knowledge of VBA, collections, object
creation, and object management.

In any case, I woud need a more detailed description of what
you are trying to achieve before launching into suggestions
for an implementation.
--
Marsh
MVP [MS Access]

Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

Marshall Barton said:
scottjr said:
i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
G

Guest

Sorry Marshall, i did not mean to upset you. It is my ingorance you are
dealing with here not my attitude.
I tried the code you posted but it gets stuck on & Me.txtMemberID.
i am trying to figure out why at the moment. i think it has something to do
with the name of my Member ID field name but if i use 9& Me.txtMember ID that
fails as well.

Your suggestion on sub forms opens another area of unknowns for me.
I will investigate that approach.
This is a learning experience for me, please keep that in mind when you get
frustrated with some of my replies.

Thanks
Jim

Marshall Barton said:
I don't understand. The code I posted will open some other
form (based on the "sub table") to the same ID as the
currently selected record in the members form. What about
this don't you like?

Actually, the usual approach to this kind of thing is to use
a subform instead of opening another form. Have you
investigated this scenario and rejected it? If so, why?

The only other interpretation I can put to your question is
that you want to open 10(?) copies of the other form at the
same time. This doesn't make a lot of sense to me because
it would make your screen so cluttered you wouldn't be able
to see anything useful. If this is what you really want to
do, be advised that this is a fairly advanced topic that
requires a significant knowledge of VBA, collections, object
creation, and object management.

In any case, I woud need a more detailed description of what
you are trying to achieve before launching into suggestions
for an implementation.
--
Marsh
MVP [MS Access]

Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

Marshall Barton said:
scottjr wrote:

i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
R

Rick Brandt

scottjr said:
Sorry Marshall, i did not mean to upset you. It is my ingorance you
are dealing with here not my attitude.
I tried the code you posted but it gets stuck on & Me.txtMemberID.
i am trying to figure out why at the moment. i think it has
something to do with the name of my Member ID field name but if i use
9& Me.txtMember ID that fails as well.

If your field or control names include spaces (bad idea) then you need to
surround them with square brackets. Try...

Me![Member ID]
 
M

Marshall Barton

Sorry, I didn't intend to come across as "upset". If
anything, I am felling frustration in my attempt to
understand what you need here.

I think your current difficulty may be that you need to
replace the names I used with the names you actually have in
your form and table:

Replace Member ID by the name of the field in the
table/query that is the record source of the "other" form
we're trying to open.

Replace txtMemberID with the name of the text box control on
the members form that is bound to the member ID field in the
table.

Note Rick's comment about names with spaces or other funky
characters.

It facilitates communication if you use the exact names of
whatever objects are being discussed so we don't have to
guess what object you are referring to and you don't have to
figure out what our guesses mean to you. Another thing that
helps us help you is if you use Copy/Paste whenever posting
any code or query SQL statements. This way we we will not
have to waste time debugging typos.

As for experimenting with a subform, it is very easy.
First, make a copy of the two forms so you can undo any
false starts. (Just use Copy/Paste in the database window.)
Then drag the "other" form and drop it in the form footer
(not page footer) or detail section of the members form.
Check to make sure that the subform control's Link
Master/Child properties contain the names of the member id
field in the two tables. That's all there is to it, no code
at all.
--
Marsh
MVP [MS Access]

Sorry Marshall, i did not mean to upset you. It is my ingorance you are
dealing with here not my attitude.
I tried the code you posted but it gets stuck on & Me.txtMemberID.
i am trying to figure out why at the moment. i think it has something to do
with the name of my Member ID field name but if i use 9& Me.txtMember ID that
fails as well.

Your suggestion on sub forms opens another area of unknowns for me.
I will investigate that approach.
This is a learning experience for me, please keep that in mind when you get
frustrated with some of my replies.


Marshall Barton said:
I don't understand. The code I posted will open some other
form (based on the "sub table") to the same ID as the
currently selected record in the members form. What about
this don't you like?

Actually, the usual approach to this kind of thing is to use
a subform instead of opening another form. Have you
investigated this scenario and rejected it? If so, why?

The only other interpretation I can put to your question is
that you want to open 10(?) copies of the other form at the
same time. This doesn't make a lot of sense to me because
it would make your screen so cluttered you wouldn't be able
to see anything useful. If this is what you really want to
do, be advised that this is a fairly advanced topic that
requires a significant knowledge of VBA, collections, object
creation, and object management.

In any case, I woud need a more detailed description of what
you are trying to achieve before launching into suggestions
for an implementation.

Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

:

scottjr wrote:

i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
G

Guest

Yeah your frustration level is directly related to my ingorance.
Sub forms worked great. thank you Marshall and Rick.

But... here is the next task.
i need for the current records displayed in now perfect form "SearchMembers"
and subform "dogs" to fill fields in another form.
the third form "entry" started as a pdf form. but since i am still trying to
figure out the input data thing there (xml maybe) i will stay with access for
now.
i have created an access form "entry" with the required fields but don't
know where to go from there.

Marshall Barton said:
Sorry, I didn't intend to come across as "upset". If
anything, I am felling frustration in my attempt to
understand what you need here.

I think your current difficulty may be that you need to
replace the names I used with the names you actually have in
your form and table:

Replace Member ID by the name of the field in the
table/query that is the record source of the "other" form
we're trying to open.

Replace txtMemberID with the name of the text box control on
the members form that is bound to the member ID field in the
table.

Note Rick's comment about names with spaces or other funky
characters.

It facilitates communication if you use the exact names of
whatever objects are being discussed so we don't have to
guess what object you are referring to and you don't have to
figure out what our guesses mean to you. Another thing that
helps us help you is if you use Copy/Paste whenever posting
any code or query SQL statements. This way we we will not
have to waste time debugging typos.

As for experimenting with a subform, it is very easy.
First, make a copy of the two forms so you can undo any
false starts. (Just use Copy/Paste in the database window.)
Then drag the "other" form and drop it in the form footer
(not page footer) or detail section of the members form.
Check to make sure that the subform control's Link
Master/Child properties contain the names of the member id
field in the two tables. That's all there is to it, no code
at all.
--
Marsh
MVP [MS Access]

Sorry Marshall, i did not mean to upset you. It is my ingorance you are
dealing with here not my attitude.
I tried the code you posted but it gets stuck on & Me.txtMemberID.
i am trying to figure out why at the moment. i think it has something to do
with the name of my Member ID field name but if i use 9& Me.txtMember ID that
fails as well.

Your suggestion on sub forms opens another area of unknowns for me.
I will investigate that approach.
This is a learning experience for me, please keep that in mind when you get
frustrated with some of my replies.


Marshall Barton said:
I don't understand. The code I posted will open some other
form (based on the "sub table") to the same ID as the
currently selected record in the members form. What about
this don't you like?

Actually, the usual approach to this kind of thing is to use
a subform instead of opening another form. Have you
investigated this scenario and rejected it? If so, why?

The only other interpretation I can put to your question is
that you want to open 10(?) copies of the other form at the
same time. This doesn't make a lot of sense to me because
it would make your screen so cluttered you wouldn't be able
to see anything useful. If this is what you really want to
do, be advised that this is a fairly advanced topic that
requires a significant knowledge of VBA, collections, object
creation, and object management.

In any case, I woud need a more detailed description of what
you are trying to achieve before launching into suggestions
for an implementation.


scottjr wrote:
Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

:

scottjr wrote:

i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
M

Marshall Barton

Base the Entry form on a query that Joins the members table
and the Dogs table. First, create a new query and add both
tables. Then check to make sure that there is a connecting
line between the MemberID fields. If there is a line but
its between the wrong fields, right click on it and delete
it. If there is no line, drag the MemberID field from one
table to the corresponding field in the other table.

Drag the appropriate fields from the tables down to the
Fields row.

To restrict the query to the currently displayed record on
the members form, use a criteria like this in the Criteria
row under the MemberID field:
Forms!SearchMembers.[Member ID]

Make sure the SearchMembers form is open and the test the
query to make sure it displays the correct data.

Once you have that working, set the Entry form's
RecordSource property to the name of the query.

To keep the Entry form in sync with the members form, add a
line of code to the members form's Current event procedure:
Forms!Entry.Requery
--
Marsh
MVP [MS Access]

Yeah your frustration level is directly related to my ingorance.
Sub forms worked great. thank you Marshall and Rick.

But... here is the next task.
i need for the current records displayed in now perfect form "SearchMembers"
and subform "dogs" to fill fields in another form.
the third form "entry" started as a pdf form. but since i am still trying to
figure out the input data thing there (xml maybe) i will stay with access for
now.
i have created an access form "entry" with the required fields but don't
know where to go from there.

Marshall Barton said:
Sorry, I didn't intend to come across as "upset". If
anything, I am felling frustration in my attempt to
understand what you need here.

I think your current difficulty may be that you need to
replace the names I used with the names you actually have in
your form and table:

Replace Member ID by the name of the field in the
table/query that is the record source of the "other" form
we're trying to open.

Replace txtMemberID with the name of the text box control on
the members form that is bound to the member ID field in the
table.

Note Rick's comment about names with spaces or other funky
characters.

It facilitates communication if you use the exact names of
whatever objects are being discussed so we don't have to
guess what object you are referring to and you don't have to
figure out what our guesses mean to you. Another thing that
helps us help you is if you use Copy/Paste whenever posting
any code or query SQL statements. This way we we will not
have to waste time debugging typos.

As for experimenting with a subform, it is very easy.
First, make a copy of the two forms so you can undo any
false starts. (Just use Copy/Paste in the database window.)
Then drag the "other" form and drop it in the form footer
(not page footer) or detail section of the members form.
Check to make sure that the subform control's Link
Master/Child properties contain the names of the member id
field in the two tables. That's all there is to it, no code
at all.

Sorry Marshall, i did not mean to upset you. It is my ingorance you are
dealing with here not my attitude.
I tried the code you posted but it gets stuck on & Me.txtMemberID.
i am trying to figure out why at the moment. i think it has something to do
with the name of my Member ID field name but if i use 9& Me.txtMember ID that
fails as well.

Your suggestion on sub forms opens another area of unknowns for me.
I will investigate that approach.
This is a learning experience for me, please keep that in mind when you get
frustrated with some of my replies.


:
I don't understand. The code I posted will open some other
form (based on the "sub table") to the same ID as the
currently selected record in the members form. What about
this don't you like?

Actually, the usual approach to this kind of thing is to use
a subform instead of opening another form. Have you
investigated this scenario and rejected it? If so, why?

The only other interpretation I can put to your question is
that you want to open 10(?) copies of the other form at the
same time. This doesn't make a lot of sense to me because
it would make your screen so cluttered you wouldn't be able
to see anything useful. If this is what you really want to
do, be advised that this is a fairly advanced topic that
requires a significant knowledge of VBA, collections, object
creation, and object management.

In any case, I woud need a more detailed description of what
you are trying to achieve before launching into suggestions
for an implementation.


scottjr wrote:
Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

:

scottjr wrote:

i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 
G

Guest

You are the best!
we are very fortunate to have a resource like this available to us.
What did we do before the internet?
I think i remember what a library is like....

Thanks again.

Jim

Marshall Barton said:
Base the Entry form on a query that Joins the members table
and the Dogs table. First, create a new query and add both
tables. Then check to make sure that there is a connecting
line between the MemberID fields. If there is a line but
its between the wrong fields, right click on it and delete
it. If there is no line, drag the MemberID field from one
table to the corresponding field in the other table.

Drag the appropriate fields from the tables down to the
Fields row.

To restrict the query to the currently displayed record on
the members form, use a criteria like this in the Criteria
row under the MemberID field:
Forms!SearchMembers.[Member ID]

Make sure the SearchMembers form is open and the test the
query to make sure it displays the correct data.

Once you have that working, set the Entry form's
RecordSource property to the name of the query.

To keep the Entry form in sync with the members form, add a
line of code to the members form's Current event procedure:
Forms!Entry.Requery
--
Marsh
MVP [MS Access]

Yeah your frustration level is directly related to my ingorance.
Sub forms worked great. thank you Marshall and Rick.

But... here is the next task.
i need for the current records displayed in now perfect form "SearchMembers"
and subform "dogs" to fill fields in another form.
the third form "entry" started as a pdf form. but since i am still trying to
figure out the input data thing there (xml maybe) i will stay with access for
now.
i have created an access form "entry" with the required fields but don't
know where to go from there.

Marshall Barton said:
Sorry, I didn't intend to come across as "upset". If
anything, I am felling frustration in my attempt to
understand what you need here.

I think your current difficulty may be that you need to
replace the names I used with the names you actually have in
your form and table:

Replace Member ID by the name of the field in the
table/query that is the record source of the "other" form
we're trying to open.

Replace txtMemberID with the name of the text box control on
the members form that is bound to the member ID field in the
table.

Note Rick's comment about names with spaces or other funky
characters.

It facilitates communication if you use the exact names of
whatever objects are being discussed so we don't have to
guess what object you are referring to and you don't have to
figure out what our guesses mean to you. Another thing that
helps us help you is if you use Copy/Paste whenever posting
any code or query SQL statements. This way we we will not
have to waste time debugging typos.

As for experimenting with a subform, it is very easy.
First, make a copy of the two forms so you can undo any
false starts. (Just use Copy/Paste in the database window.)
Then drag the "other" form and drop it in the form footer
(not page footer) or detail section of the members form.
Check to make sure that the subform control's Link
Master/Child properties contain the names of the member id
field in the two tables. That's all there is to it, no code
at all.


scottjr wrote:
Sorry Marshall, i did not mean to upset you. It is my ingorance you are
dealing with here not my attitude.
I tried the code you posted but it gets stuck on & Me.txtMemberID.
i am trying to figure out why at the moment. i think it has something to do
with the name of my Member ID field name but if i use 9& Me.txtMember ID that
fails as well.

Your suggestion on sub forms opens another area of unknowns for me.
I will investigate that approach.
This is a learning experience for me, please keep that in mind when you get
frustrated with some of my replies.


:
I don't understand. The code I posted will open some other
form (based on the "sub table") to the same ID as the
currently selected record in the members form. What about
this don't you like?

Actually, the usual approach to this kind of thing is to use
a subform instead of opening another form. Have you
investigated this scenario and rejected it? If so, why?

The only other interpretation I can put to your question is
that you want to open 10(?) copies of the other form at the
same time. This doesn't make a lot of sense to me because
it would make your screen so cluttered you wouldn't be able
to see anything useful. If this is what you really want to
do, be advised that this is a fairly advanced topic that
requires a significant knowledge of VBA, collections, object
creation, and object management.

In any case, I woud need a more detailed description of what
you are trying to achieve before launching into suggestions
for an implementation.


scottjr wrote:
Pull a form does mean open a form. i can do that much so far.
This is the part i cannot get to yet.

Every memberID displayed in the search members form (each record in the
member table) requires a form to open that is attached to that memberID sub
table (Dogs).
If there are 10 members in the members table, the search members form button
would have to open 10 different forms each attached to a memberID.

memberID 33 has basic info in members table
memberID 33 has dogs owned record in the sub table linked to memberID 33

:

scottjr wrote:

i am not sure where this question should be posted. i am guessing somewhere
around here.
i have a table with detailed member information (memberID name, address,
etc.) each member ID has a sub table that has additional info about that
member ID.
i have a form that searches members by last name and displays some of the
fields from the membership table.
I would like to add a button on the form that will pull a form showing the
sub table info related to the member ID record currently displayed.
I have added a button that will pull a sub form unrelated to the member ID
displayed but i am stuck there.


Assuming "pull a form" really means open a form, just use
the OpenForm method's WhereCondition argument:

Dim strWhere As String
. . .
strWhere = "[Member ID] = " & Me.txtMemberID
. . .
DoCmd.OpenForm . . ., WhereCondition:=strWhere
 

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