Opening another form and access same record on previous form

  • Thread starter Thread starter Vic Abrahamian
  • Start date Start date
V

Vic Abrahamian

Hi everyone,
I need help to figure out a way to open a second form and accessing the same
record as I had open in the previous form. The second form is accessing the
same table but give me a different view of the record.
Thank you
 
You can do this a couple ways. You can use the form open criteria or
the open arguments.

Open arguments example:

DoCmd.OpenForm "frmName", acNormal, , , acFormEdit, , me.[PrimaryKey]



Then on the Load Event of the second form:

me.[PrimaryKey] = Me.OpenArgs



In the event you use that 2nd form for entering new records, you might
want to put an if statement around that Load event so it only loads it
when it exists.
 
On the first form, create a command button. Go to the properties of
that button, and to the Event tab, find the event On Click, and choose
[Event Procedure]. Click on the small button beside this with the
"..." to launch VBA editor. Copy this for this code for the event
(substituting the correct form name, and name of field for primary
key):
DoCmd.OpenForm "frmName", acNormal, , , acFormEdit, , me.[PrimaryKey]


Then go to properties of 2nd form, Event tab, find the event On Load,
and choose Event Procedure. Click on the small button beside this
with the "..." to launch VBA editor.
copy this code (again putting in the correct name of your primary key
field):

me.[PrimaryKey] = Me.OpenArgs
 
HI and thanks for your suggetions...i am running the below code but something
goes wrong.

Form A, a continous form based on a query, i applied the command button to
open Form B with the corresponding record (Form B is a single form) but i get
the error message "can not assign value to this object...
 
Back
Top