[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

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
0
SteveL13
Asked:
SteveL13
  • 3
  • 2
1 Solution
 
flavoCommented:
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
0
 
SteveL13Author Commented:
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.
0
 
flavoCommented:
Gotcha! My mistake!!

    DoCmd.OpenForm "frmFinancialInfo", acNormal
    DoCmd.GoToRecord acActiveDataObject, "frmFinancialInfo", acNewRec
    Form_frmFinancialInfo.txtJobN.Value = Me.txtJobN.Value
    Form_frmFinancialInfo.txtDetailID.Value = Me.txtDetailID.Value
0
 
SteveL13Author Commented:
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.
0
 
SteveL13Author Commented:
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.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now