Learn how to a build a cloud-first strategyRegister Now


How have field on a form auto-populate with a data field from another form

Posted on 2014-08-06
Medium Priority
Last Modified: 2014-08-11
I have a form that can be opened via a command button from four other forms.  When the 2nd form opens I want a date field to automatically populate from a date field that is in the 1st form.

But since this date field on the 2nd form can be opened from any one of 4 forms, I am not sure how to populate the date field,  Somehow the 2nd form has to know which of the 4 forms is open and use the date field from that form.


Question by:SteveL13
LVL 40

Expert Comment

ID: 40244738
There are several solutions.  Here's two.

1. Before opening the pop up form, store the date in a memory variable.  That way the pop up form gets the date from a memory variable and doesn't care what form put it there.
2. Use the open args argument of the OpenForm Method to pass in the date.
LVL 31

Accepted Solution

Helen Feddema earned 2000 total points
ID: 40244757
From the command button on each form, open the 2nd form, get the Date value from the calling form, using the syntax Me![txtDateField].Value, and write it to the appropriate Date field control on the other form, using the syntax Forms![frmSecondform]![txtDateField].Value.  You can do some error trapping if you wish.  Here is some sample code:
Private Sub cmdOpentargetform_Click()

   Dim dteStart As Date
   Dim frm As Access.Form
   If IsDate(Me![txtStartDate].Value) = True Then
      dteStart = Me![txtStartDate].Value
      DoCmd.OpenForm "frmTarget"
      Set frm = Forms![frmTarget]
      frm![txtStartDate] = dteStart
   End If
End Sub

Open in new window


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

810 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