How to re-read database for record with a key passed as an argument?

I have two forms: one a list of Products; and second, an edit page of additional Product information.  I have an event on On Dbl_Click on the List page with the following code:

DoCmd.OpenForm "Product_Edit", acNormal, , , acFormEdit, acDialog, Product_Nbr.Value

While I am able to see the Product_Nbr Argument being passed into the Product_Edit form, I'm not able to have this second form display this particular record.  It only displays the first record in the Product table.  

How to I tell Access to re-read the product table based on the Product_Nbr being passed into it?


Thanks....

Andre.
0
LVL 9

Expert Comment

by:Armen Stein - Microsoft Access MVP since 2006
Hi Andre,

You are sending in Product_Nbr as an OpenArgs parameter, which is available to the called form but nothing else is done with it automatically.  It sounds like you want to use the WhereCondition parameter instead, which is the fourth one.  To keep everything clear, I recommend using named parameters instead of counting commas.  So, your statement will look something like:

DoCmd.OpenForm FormName:="Product_Edit", WhereCondition:="ProductNbr = " & Me.ProductNbr, WindowMode:=acDialog

More help on the OpenForm command's parameters:
https://docs.microsoft.com/en-us/office/vba/api/access.docmd.openform

Hope this helps,
Armen Stein
J Street Technology
0
LVL 27

Expert Comment

by:Brian B
You have entered this as a post not a question, so most Experts will not see it. If you still need assistance you may want to repost this using the "ask a question" button.
0

Author Comment

by:Andre Fischer
Thank you for your assistance.  I was able to get it to work by specifying the Filter as:

WhereCondition:="Products.[Product-Nbr] = " & Me.Product_Nbr.Value,


Andre.
0

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month