Solved

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

Posted on 2014-01-29
3
1,334 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 250 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 30

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

Technology Partners: 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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

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