coding between subforms

K

Krykota

In Access 2007, I have a main form housing a tab control. On one page of my
tab control, I have two subforms. The first subform lists my customers
getting the data from a query in which I merge the first and last names and
have a customer id (two fields). This form presents data in a continuous
form list. The second subform has the detailed information on the customer.

My goal and intent is to be able to click either on a button (linked to the
customer id), the name of the customer, or even utilize toggle buttons (in
which the caption is the customer name - preferred as a method to highlight
the selected customer) and the detailed data on the customer is displayed in
the second subform.

I have tried doing an OnClick macro on the name, however, I am unable to
direct my attention into the correct form (says it cannot find the form) even
when I use the wizard to create the macro.

Any help is greatly appreciated.

Thanks in advance!!!
 
J

Jeff Boyce

When referring to an embedded subform, you need to call out the complete
path. Something like (untested):

Forms!YourMainForm!YourSubformControlName.Form!YourControlOnSubform


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
M

Marshall Barton

Krykota said:
In Access 2007, I have a main form housing a tab control. On one page of my
tab control, I have two subforms. The first subform lists my customers
getting the data from a query in which I merge the first and last names and
have a customer id (two fields). This form presents data in a continuous
form list. The second subform has the detailed information on the customer.

My goal and intent is to be able to click either on a button (linked to the
customer id), the name of the customer, or even utilize toggle buttons (in
which the caption is the customer name - preferred as a method to highlight
the selected customer) and the detailed data on the customer is displayed in
the second subform.

I have tried doing an OnClick macro on the name, however, I am unable to
direct my attention into the correct form (says it cannot find the form) even
when I use the wizard to create the macro.

I don't do macros, but if you can live with a little VBA
code or can translate VBA to a macro, you can synchronize
two subforms automatically without a button or any other
user action.

Add a hidden text box (named txtLink) to the main form.
Then add a line of VBA code to the continuous subform's
Current event procedure:
Parent.txtLink = Me.theprimarykeyfield

With that in place, the single view subform control can set
the Link Master property to txtLink and the Link Child
property to theprimarykeyfield.

This way the single view subform will always display the
details for whatever record you make current in the
continuous subform, regardless of how you navigate to it.
 
K

Krykota

Jeff, thanks for the reply.

I verified that the path is complete and I still get the message that Access
cannot find what I ask of it.

Here is what I have as an OnClick event:

Forms!RepairLab!Form!CustomerDetail!CustomerID =
Forms!RepairLab!Form!CustomerList![CustomerID]

The idea is that by clicking on the name of the customer, the accompanying
subform CustomerDetail will filter to display the information on the customer
selected in the CustomerList subform. There are two subforms on one tab
control page form.

Would putting a hidden CustomerID control on the main form help link the two
subforms to allow for the filtering? If so, how would I direct focus from
the list to the detail?
 
J

Jeff Boyce

The expression you posted does not use the same syntax as the expression I
offered.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


Krykota said:
Jeff, thanks for the reply.

I verified that the path is complete and I still get the message that
Access
cannot find what I ask of it.

Here is what I have as an OnClick event:

Forms!RepairLab!Form!CustomerDetail!CustomerID =
Forms!RepairLab!Form!CustomerList![CustomerID]

The idea is that by clicking on the name of the customer, the accompanying
subform CustomerDetail will filter to display the information on the
customer
selected in the CustomerList subform. There are two subforms on one tab
control page form.

Would putting a hidden CustomerID control on the main form help link the
two
subforms to allow for the filtering? If so, how would I direct focus from
the list to the detail?

Jeff Boyce said:
When referring to an embedded subform, you need to call out the complete
path. Something like (untested):

Forms!YourMainForm!YourSubformControlName.Form!YourControlOnSubform


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.




.
 
K

Krykota

My apologies Jeff. I will be more attentitive in the future. Thanks for your
response.

Jeff Boyce said:
The expression you posted does not use the same syntax as the expression I
offered.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


Krykota said:
Jeff, thanks for the reply.

I verified that the path is complete and I still get the message that
Access
cannot find what I ask of it.

Here is what I have as an OnClick event:

Forms!RepairLab!Form!CustomerDetail!CustomerID =
Forms!RepairLab!Form!CustomerList![CustomerID]

The idea is that by clicking on the name of the customer, the accompanying
subform CustomerDetail will filter to display the information on the
customer
selected in the CustomerList subform. There are two subforms on one tab
control page form.

Would putting a hidden CustomerID control on the main form help link the
two
subforms to allow for the filtering? If so, how would I direct focus from
the list to the detail?

Jeff Boyce said:
When referring to an embedded subform, you need to call out the complete
path. Something like (untested):

Forms!YourMainForm!YourSubformControlName.Form!YourControlOnSubform


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

In Access 2007, I have a main form housing a tab control. On one page
of
my
tab control, I have two subforms. The first subform lists my customers
getting the data from a query in which I merge the first and last names
and
have a customer id (two fields). This form presents data in a
continuous
form list. The second subform has the detailed information on the
customer.

My goal and intent is to be able to click either on a button (linked to
the
customer id), the name of the customer, or even utilize toggle buttons
(in
which the caption is the customer name - preferred as a method to
highlight
the selected customer) and the detailed data on the customer is
displayed
in
the second subform.

I have tried doing an OnClick macro on the name, however, I am unable
to
direct my attention into the correct form (says it cannot find the
form)
even
when I use the wizard to create the macro.

Any help is greatly appreciated.

Thanks in advance!!!


.


.
 
K

Krykota

Marshall, thank you for your help. SPOT ON!!!!!! Quick, easy, and highly
functional.

THANK YOU!!!!
 

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