Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passing Information to New (Add, not Edit) Access Forms

Posted on 2014-01-29
3
Medium Priority
?
1,531 Views
Last Modified: 2014-01-30
I'm working on building a database through Access 2010 which will keep track of jobs and "records" (here, essentially components of a job, like a bid).  These two aspects of a job are in their own, separate tables, with the Primary Key of the JobT Table being a foreign key in RecordT.  I currently have a Navigation Form set up with a subform that displays a list of current records/bids.  At the end of this subform, I have a button labelled "Job Info" that leads to a different form that displays all the details of this job, and includes a subform of the bids that make up a job.  There is another button, right next to this one, that opens a form with details about the bid (call it Record Info).  Both of these forms allow reading as well as writing information, and this is by design.

My question is:  is there any way to open the "Record Info" and pass specific values to certain fields on the new form?  In this case, I'd like to pass only the JobID value into the new form only when the button on the Job Info form is pressed (along with other job-specific things that can be brought over if I have this JobID field (which is a Primary Key)).

Essentially, I would like to re-use the Record Info form thusly:
1: pressing the "record info" button at the end of a line in a subform should open that record's information.
2: pressing the "log new record" button (on the Job Info form) should open this form in data entry mode, automatically passing and pulling certain information based on information in the form that called this one.

The end result of this form's submittal should be that the new record is added to the RecordT table, and it should be automatically assigned to the appropriate job.  This can be accomplished using a dialog box or text/combobox, whichever seems simpler.

Thanks in advance!
0
Comment
Question by:calwood28
[X]
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 Comments
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 1000 total points
ID: 39819750
Hello calwood28

To achieve #1, pass the RecordID from the current record as a WhereCondition when you open the form:
DoCmd.OpenForm "Record Info", _
        WhereCondition:="RecordID=" & Me.RecordID, _
        WindowMode:=acDialog

Open in new window


For #2, open the form in DataEntry mode and pass the JobID through the form's OpenArgs:
DoCmd.OpenForm "Record Info", _
        DataMode:=acFormAdd, _
        WindowMode:=acDialog, _
        OpenArgs:=Me.JobID
' then requery the subform
Me.[Name of subform control].Form.Requery

Open in new window


In the form's Load event procedure, check for DataEntry mode and set the DefaultValue of the JobID textbox to the passed value:
If Me.DataEntry Then Me.JobID.DefaultValue = Me.OpenArgs

Open in new window


The reason for using .DefaultValue instead of just setting the .Value is that if the user changes her mind and closes the form immediately, no new record will have been created to undo.

Best wishes,
Graham Mandeno [Access MVP 1996-2014]
0
 
LVL 31

Expert Comment

by:hnasr
ID: 39819812
One way:
Have unbound controls on the calling form.
Populate the controls with relevant values when clicking respective button.
In the open form in new record, use the previous controls.
0
 

Author Closing Comment

by:calwood28
ID: 39821960
That worked wonderfully, thanks.
0

Featured Post

Industry Leaders: 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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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