Help with opening a 'pop up' form with the right record

  • Thread starter Corey-g via AccessMonster.com
  • Start date
C

Corey-g via AccessMonster.com

Hi All,

I have a main form that displays products, and I need to build a 'pop up'
form to display information about the product selected on the main form. I
have a query as the source of the pop up currently, but I'm not sure how to
have the pop up on the right record when it opens. Do I need to create a
parameter query, and then do some VBA in the pop up forms 'On_Load/Open'
event?

I am currently using the 'openargs' to pass the product ID, but what do I
need to do to have the form pop up to that record?

Thanks,

Corey
 
F

fredg

Hi All,

I have a main form that displays products, and I need to build a 'pop up'
form to display information about the product selected on the main form. I
have a query as the source of the pop up currently, but I'm not sure how to
have the pop up on the right record when it opens. Do I need to create a
parameter query, and then do some VBA in the pop up forms 'On_Load/Open'
event?

I am currently using the 'openargs' to pass the product ID, but what do I
need to do to have the form pop up to that record?

Thanks,

Corey

Just use the Where condition argument in the OpenForm method.

If [ProductID] is a Number datatype:
DoCmd.OpenForm "FormName", , ,"[ProductID] = " & Me![ProductID], ,
acDialog

If [ProductID] is a Text datatype:
DoCmd.OpenForm "FormName", , ,"[ProductID] = '" & Me![ProductID] &
"'", , acDialog
 
C

Corey-g via AccessMonster.com

I'd never used that before... What a great idea!

Now when I do that, I get the "Name#" in all of the fields. I think that the
reason is because the product ID is quoted when referenced.
I put in a breakpoint at the openform call, and when I hoover over the me.
product_ID in the where clause it shows:
me.product_ID = "111"

Is that correct?
 
F

fredg

I'd never used that before... What a great idea!

Now when I do that, I get the "Name#" in all of the fields. I think that the
reason is because the product ID is quoted when referenced.
I put in a breakpoint at the openform call, and when I hoover over the me.
product_ID in the where clause it shows:
me.product_ID = "111"

Is that correct?

Did you use the correct syntax for whether [Product_ID] is a Number
datatype or Text?

If Product_ID is a number datatype and you used the correct syntax of

DoCmd.OpenForm "FormName", , ,"[Product_ID] = " & Me![Product_ID] , ,
acDialog
hovering over the text should show
me.product_ID = 111 (no quotes)

If Prduct_ID is Text datatype, then the syntax of:

DoCmd.OpenForm "FormName", , ,"[Product_ID] = '" & Me![Product_ID] &
"'", , acDialog

hovering over the syntax, the value should read
me.product_ID = "111" (With quotes)
 
C

Corey-g via AccessMonster.com

Thanks Fredg...

It was more of a stupid mistake on my part, not your code. I had cleared the
recordsource of the form to assign dynamically before I posted the Q, then
attempted to add a where clause as you suggested. Once I put the source back
in everything worked as it was supposed to.

Thanks again - I had forgotten all about the where clause of the open form
command. Guess that's what happens when you continually switch development
environments...

Corey
 

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