pop up forms that open to the same record as my main form, how?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have set up a command button to open my macro (openform) with the event as
on click. This works great and is what I want, except I want the pop up form
to open the the same record as my main form. I have not created these forms
as sub forms for I do not want all the information on the same form (it's way
to big).
 
I think it's as simple as specifying a WHERE condition in your open form
command. Whatever the primary key is, you should make your where condition
set that field on the pop up form equal to the primary key field that is on
the main form.

Let's say the main form displays info about employees and the primary key is
EmployeeID. If you want your button to bring up a separate form showing info
from the same record as the main form's current record, the where condition
in the "open form" command should be something like:

[EmployeeID] = Me.[txtbxEmployeeID]

I think that should do it. Good luck.

-ndalton
 
I have set up a command button to open my macro (openform) with the event as
on click. This works great and is what I want, except I want the pop up form
to open the the same record as my main form. I have not created these forms
as sub forms for I do not want all the information on the same form (it's way
to big).

Each record should have a Unique Prime Key field.
Assuming the Prime Key field is a Number datatype:

DoCmd.OpenForm "Form2", , , "[RecordID] = " & [RecordID], , acDialog


If the Prime Key foeld is a Text datatype, then:

DoCmd.OpenForm "Form2", , , "[RecordID] = '" & [RecordID] & "'", ,
acDialog
 
I think I might be doing this wrong.

My primary key is Property ID
My Master form is Historical Information
My pop up form is Owner History, Text.

As of write now, my macro reads in the Where Condition...
[Forms]![Historical Information].[OnClick]

Is this where I should be typing...
DoCmd.OpenForm "Owner History", , , "[PropertyID] = '" &
[PropertyID] & "'", , acDialog

Thanks.....

fredg said:
I have set up a command button to open my macro (openform) with the event as
on click. This works great and is what I want, except I want the pop up form
to open the the same record as my main form. I have not created these forms
as sub forms for I do not want all the information on the same form (it's way
to big).

Each record should have a Unique Prime Key field.
Assuming the Prime Key field is a Number datatype:

DoCmd.OpenForm "Form2", , , "[RecordID] = " & [RecordID], , acDialog


If the Prime Key foeld is a Text datatype, then:

DoCmd.OpenForm "Form2", , , "[RecordID] = '" & [RecordID] & "'", ,
acDialog
 
I think I might be doing this wrong.

My primary key is Property ID
My Master form is Historical Information
My pop up form is Owner History, Text.

As of write now, my macro reads in the Where Condition...
[Forms]![Historical Information].[OnClick]

Is this where I should be typing...
DoCmd.OpenForm "Owner History", , , "[PropertyID] = '" &
[PropertyID] & "'", , acDialog

Thanks.....

fredg said:
I have set up a command button to open my macro (openform) with the event as
on click. This works great and is what I want, except I want the pop up form
to open the the same record as my main form. I have not created these forms
as sub forms for I do not want all the information on the same form (it's way
to big).

Each record should have a Unique Prime Key field.
Assuming the Prime Key field is a Number datatype:

DoCmd.OpenForm "Form2", , , "[RecordID] = " & [RecordID], , acDialog

If the Prime Key foeld is a Text datatype, then:

DoCmd.OpenForm "Form2", , , "[RecordID] = '" & [RecordID] & "'", ,
acDialog

I have no idea what you mean by "My pop up form is Owner History,
Text"
Your pop up form is a form.
All you need to know is what the datatype is of the [PropertyID] field
that is used as the Prime Key field.

Forget that macro.

On the Master Form, display it's property sheet.
Click on the Events tab.
On the OnClick event line, write:
[Event Procedure]
Then click on the button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

DoCmd.OpenForm "Owner History", , , "[PropertyID] = '" & PropertyID]
& "'", , acDialog

This assumes that the datatype of the [PropertyID] field is Text
datatype.

If [PropertyID] is not text, but rather a Number datatype, then use

DoCmd.OpenForm "Owner History", , , "[PropertyID] = " & PropertyID] ,
, acDialog

Close the code window.

Open the Master form. When you click on the command button, the "Owner
History" form will open to the record that matches the [PropertyID]
field. The "Owner History" form will retain the focus until you close
or hide it, at which point the Master form will regain focus.
 
Back
Top