Open second form based off first form

T

TKM

When a customer is on a certain record I would like to be able to view
certain informtion from the first form onto the second form. How do I keep
them equal. I am only getting the first recod.
 
J

Jeanette Cunningham

Hi TKM,
you can do it like this:

DoCmd.OpenForm "NameOfForm", , , "[PKey] = " & Me.PKeyControlName & ""

replace :
NameOfForm with the name of the second form
[PKey] with the name of the primary key field on the first form
Me.PKeyControlName with the name of the control on the first form that has
the PKey as its data source.

The above will tell the second form to open showing the record that has the
same PKey as the record selected on the first form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
T

TKM

What portion do I chage on the last part? the entire PKeyControlName or Just
the Control name? I dont understand what you mean by "name of the control on
the first form that has
the PKey as its data source.
" thank you

Jeanette Cunningham said:
Hi TKM,
you can do it like this:

DoCmd.OpenForm "NameOfForm", , , "[PKey] = " & Me.PKeyControlName & ""

replace :
NameOfForm with the name of the second form
[PKey] with the name of the primary key field on the first form
Me.PKeyControlName with the name of the control on the first form that has
the PKey as its data source.

The above will tell the second form to open showing the record that has the
same PKey as the record selected on the first form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


TKM said:
When a customer is on a certain record I would like to be able to view
certain informtion from the first form onto the second form. How do I keep
them equal. I am only getting the first recod.
 
J

Jeanette Cunningham

If you have a text box with the primay key of the table/query used for the
form's record source - use the contol's name.

If you don't have a text box with the primary key, then instead use:

DoCmd.OpenForm "NameOfForm", , , "[PKey] = " & Me.PKey & ""

Where PKey is the name of the Primary key field in the table/query used for
the form's record source.


Example if your form was based on a query based on an Orders table, with
primay key of OrderID,
it would be
DoCmd.OpenForm "NameOfForm", , , "[OrderID] = " & Me.OrderID & ""

However if you had a text box with OrderID as its data source, and the name
of the text box was txtOrderID,
then the code would look like:
DoCmd.OpenForm "NameOfForm", , , "[OrderID] = " & Me.txtOrderID & ""


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


TKM said:
What portion do I chage on the last part? the entire PKeyControlName or
Just
the Control name? I dont understand what you mean by "name of the control
on
the first form that has
the PKey as its data source.
" thank you

Jeanette Cunningham said:
Hi TKM,
you can do it like this:

DoCmd.OpenForm "NameOfForm", , , "[PKey] = " & Me.PKeyControlName & ""

replace :
NameOfForm with the name of the second form
[PKey] with the name of the primary key field on the first form
Me.PKeyControlName with the name of the control on the first form that
has
the PKey as its data source.

The above will tell the second form to open showing the record that has
the
same PKey as the record selected on the first form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


TKM said:
When a customer is on a certain record I would like to be able to view
certain informtion from the first form onto the second form. How do I
keep
them equal. I am only getting the first recod.
 
1

123

TKM said:
What portion do I chage on the last part? the entire PKeyControlName or Just
the Control name? I dont understand what you mean by "name of the control on
the first form that has
the PKey as its data source.
" thank you

Jeanette Cunningham said:
Hi TKM,
you can do it like this:

DoCmd.OpenForm "NameOfForm", , , "[PKey] = " & Me.PKeyControlName & ""

replace :
NameOfForm with the name of the second form
[PKey] with the name of the primary key field on the first form
Me.PKeyControlName with the name of the control on the first form that has
the PKey as its data source.

The above will tell the second form to open showing the record that has the
same PKey as the record selected on the first form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


TKM said:
When a customer is on a certain record I would like to be able to view
certain informtion from the first form onto the second form. How do I keep
them equal. I am only getting the first recod.
 

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