Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link two forms?

Status
Not open for further replies.

gabrielbatistuta

Technical User
Jun 21, 2007
20
0
0
US
Hi there,

I have created two forms where a selection in the first form will open the second form. These two forms are based one table, let's call it "Enhanced Work Order". The relationship is one to one. That is why I put it all in one table. I would like to be able to synchronize the two forms so that some data from first form shows up in the second form. So each form has the EWOID that is the same. But the way I created it, is that everytime I save the second form there are two records created in the underlying query.

Your help is greatly appreciated!
 
Have a look at the 4th argument of the DoCmd.OpenForm method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How do you open the second form ?
Probably with the OpenForm method, don't you ?
If so, then use a criteria (4th argument) on the just saved EWOID.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi there,

The second form is opened when the user selects a particular name from a combo box in the first form.

Could you please provide a sample code?

I have
Code:
If combobox = name

Docmd.Open("frmEWO3")


tHANKS.
 
I highly doubt the code you posted does anything else than raising an error ...
 
Please ignore the code. You mentioned the 4th argument. Could you please post a sample code that will solve the problem.

Thank you.
 
No F1 key on your keyboard ?
Place the cursor inside the OpenForm word in your code, press F1 and have a look at the sample code.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
DoCmd.OpenForm ("frmEWOPDC",,,"EWOID = )

I am a newbie in VBA. How do I say EWOID = second form EWOID control.
 
Code:
DoCmd.OpenForm "frmEWOPDC", , , "EWOID='" & Me![name of EWOID control] & "'"
If EWOID is defined as numeric in your table then get rid of the single quotes.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
DoCmd.OpenForm ("frmEWOPDC",,,"EWOID = Me![EWOID]")

First of all, please let me know if what I am doing is correct?

EWOID is the same control for both forms. So I want to say that show me the second form with EWOID that is the same as the EWOID of the first form. Both EWOID have the same control name.

So I wanted to say

EWO1.EWOID = EWO2.EWOID

Correct?
When I am editing the code I am in the first form.

So I would be

EWOID = frmEWO2.EWOID (what is the correct code for this)

Thanks a lot
 
If EWOID is numeric, then the correct code is:
Code:
Me.Dirty = False ' save the current record just in case
DoCmd.OpenForm "frmEWOPDC", , , "EWOID=" & Me![EWOID]
BTW, how is named the second form ? frmEWOPDC ? frmEWO2 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you for the code. The code just filters the second form based on the first form EWOID. I can even see that on the second form properties->filterns = EWOID = 138 which is the EWOID of the first form. But when the second form opens, no information from the first form show up in the second form and it is locked for me to type any info.
 
no information from the first form show up in the second form
How are they supposed to show ? via controls bound to the underlaying query ?
Furthermore, does the RecordSource contain at least the shared PK ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear PH,

This should be really simple to do. I don't understand why I have to go through tons of replies. If you tell me exactly what needs to be done (I already have explained what my problem is) then everything works out fine.

You told me to filter the second form when I open the first form. Now fields that are the same in both forms should show up on both forms Correct? If not, what steps need to be taken? My friend , please please be more specific.


 
I already have explained what my problem is
Sorry, but you haven't really explained how your 2 forms are built nor what you really tried.
Please, read CAREFULLY this:
FAQ181-2886
 
Furthermore, why didn't you reply to the thread you created on the VERY same topic ?
thread702-1381184
 
gabrielbatistuta said:
I don't understand why I have to go through tons of replies
You are being helped by the #2 ranked MVP in this forum. Perhaps you should reflect on that.

I notice you seem to abandon threads when the replies point to useful and relevant articles rather than spoon feeding you the answer.

Any ways, my two thoughts are:
1. You have not actually saved your record on the first form at the time when you open the second form
OR
2. The second form is set to add-only mode

Those are only guesses. It is impossible for any of us to tell you "exactly what needs to be done" because we don't know anything about your table structure or the design of your forms. I suspect part of the problem is an unnormalized database design, as it seems odd to me to upon a second form for the same record that is on the first form (Aceman asked you about this in your other thread, which you declined to answer).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top