Passing data from a subform to another form

G

Guest

I have a main form with a subform. I want to open another form when an item
is selected from the combo box on the subform. The new form looks up and
displays a record based on the combo box selection in the subform (i.e the
combo box displays product descriptions, but the Product ID is sent to the
form being opened). Everything works fine when I test it directly from the
subform (i.e. without loading the main form).

When I try to test it by loading the main form and then selecting an item
from the combo box on the subform, I am prompted for the Product ID. Why
does this happen when I am using the main form but not when I test the
subform by itself?

Thanks. Any help would be appreciated!
 
P

PC Datasheet

DoCmd.OpenForm "NameOfNewForm",,,"[ProductID] = " &
Forms!NameOfMainForm!NameOfSubformControl!ProductID

Watch the word wrap!

Note that I assume ProductID is a number and not a string.
 
G

Guest

THANKS! It worked perfectly!

DEW

PC Datasheet said:
DoCmd.OpenForm "NameOfNewForm",,,"[ProductID] = " &
Forms!NameOfMainForm!NameOfSubformControl!ProductID

Watch the word wrap!

Note that I assume ProductID is a number and not a string.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


DEW said:
I have a main form with a subform. I want to open another form when an item
is selected from the combo box on the subform. The new form looks up and
displays a record based on the combo box selection in the subform (i.e the
combo box displays product descriptions, but the Product ID is sent to the
form being opened). Everything works fine when I test it directly from the
subform (i.e. without loading the main form).

When I try to test it by loading the main form and then selecting an item
from the combo box on the subform, I am prompted for the Product ID. Why
does this happen when I am using the main form but not when I test the
subform by itself?

Thanks. Any help would be appreciated!
 

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