Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How open 2nd form based on two fields in the 1st form

I have a form, frmProjectDetail, which is bound to tblProjectDetail.  On this form are two fields, "txtJobN", and "txtDetailID".  Neither one of these fields are indexed because there can be duplicate records for "txtJobN".  However ther can only be one "txtDetailID" record number 1, number 2, number 3, etc.

On form frmProjectDetail is a command button.  When the button is clicked I want a 2nd form, "frmFinancialInfo", bound to tblFinancialInfo, to open, leaving form 1 open.  In the second form then are two fields that I want populated with the values from frmProjectDetail... the same two fields as in the 1st form.  And I want this record to be written to tblFinancialInfo after a couple other fields are filled in.

How can I do this?

--Steve
Avatar of flavo
flavo
Flag of Australia image

Something like this on the Click event for a command button should do the trick:


    DoCmd.OpenForm "frmFinancialInfo", acNormal
    Form_frmFinancialInfo.txtJobN.Value = Me.txtJobN.Value
    Form_frmFinancialInfo.txtDetailID.Value = Me.txtDetailID.Value
Avatar of SteveL13

ASKER

This isn't working quite right.  After the first record is written to the tblFinancialInfo, the same record is opened and the txtJobN and txtDetailID are overwritten with the values from frmProjectDetail using a different record.  Make sense?  I almost feel like some kind of filering needs to be applied using txtJobN and txtDetailID.
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Close.  Now the only problem is that if I select the same record as used once before from frmProjectDetail the 2nd form is ADDING a new record to tblFinancialInfo instead of overwriting the 1st record written to that table.
In other words, the record is a NEW record because the JobN and Detail ID combination has never been used before.  But if the JobN and DetailID combination HAS been used before, then I want the form to open to that record so the values in the other fields on the form can be editted.