opening a popup from subform

J

JohnE

I have a subform that is continuous. Each record has an ID field. At the
end of each record there is a small button that will open a form with fields
on it for the user to review. When the button is used and the form opens, I
need to pass the ID to the form. I went into sql mgt studio and did the
following, which is where the info is coming from for the form that opens.
This returns back the correct info.

select
InventoryLots.ID,
InventoryLotsQ.ID AS ID,
InventoryLotsQ.LotNumber,
InventoryLotsQ.PartNumber,
InventoryLotsQ.Revision,
InventoryLotsQ.Location,
InventoryLotsQ.POChargeAccount,
InventoryLotsQ.Quantity

from InventoryLots
INNER JOIN InventoryLotsQ on InventoryLots.ID = InventoryLotsQ.ID

where InventoryLots.ID = 1093891 'number from the ID field in the subform

How do I apply this to the button that opens the form and pass the info along?

Thanks... John
 
M

Marshall Barton

JohnE said:
I have a subform that is continuous. Each record has an ID field. At the
end of each record there is a small button that will open a form with fields
on it for the user to review. When the button is used and the form opens, I
need to pass the ID to the form. I went into sql mgt studio and did the
following, which is where the info is coming from for the form that opens.
This returns back the correct info.

select
InventoryLots.ID,
InventoryLotsQ.ID AS ID,
InventoryLotsQ.LotNumber,
InventoryLotsQ.PartNumber,
InventoryLotsQ.Revision,
InventoryLotsQ.Location,
InventoryLotsQ.POChargeAccount,
InventoryLotsQ.Quantity

from InventoryLots
INNER JOIN InventoryLotsQ on InventoryLots.ID = InventoryLotsQ.ID

where InventoryLots.ID = 1093891 'number from the ID field in the subform

How do I apply this to the button that opens the form and pass the info along?

If the popup form is only for viewing/editing existing
records, then you can filter the popup's data by using the
OpenForm method's WhereCondition argument:

DoCmd.OpenForm "popup form", , ,"ID=" & Me.ID

If you want to add new rcords in the popup, then you can
pass the ID value in the OpenForm method's OpenArgs
argument:

DoCmd.OpenForm "popup form", OpenArgs:= Me.ID

Check VBA Help on OpenForm for more details.
 
J

JohnE

Thanks for the reply. I was originally trying the DoCmd.OpenForm
"zPartPriceUpdate", , ,"ID=" & Me.ID
but was not working properly. So I decided to try something else. Went and
looked at what I had and I had one less comma. Stupid little errors.
Thanks.
John
 
J

John W. Vinson

Thanks for the reply. I was originally trying the DoCmd.OpenForm
"zPartPriceUpdate", , ,"ID=" & Me.ID
but was not working properly. So I decided to try something else. Went and
looked at what I had and I had one less comma. Stupid little errors.

That's why I prefer the (uglier in some ways but clearer in others)
named-argument approach:

DoCmd.OpenForm "zPartPriceUpdate", WhereCondition:="ID = " & Me.ID
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top