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

Posted on 2011-03-09
Last Modified: 2012-06-27
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?

Question by:SteveL13
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 34

Expert Comment

ID: 35089455
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

Author Comment

ID: 35089501
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.
LVL 34

Accepted Solution

flavo earned 500 total points
ID: 35089538
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

Author Comment

ID: 35089570
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.

Author Comment

ID: 35089605
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.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
microsoft Accesss Basic Coding 44 70
Microsoft Access 2016 Bug? 9 47
Union & Crosstab qrys 101! 6 59
Access #Deleted data 20 45
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question