How to open a popup form already filtered

D

Dave

I have a form with a list of products.
Each product has a unique product ID but could have several that have the
same name and the only difference being (other then a different productID)
is they are different colors.
I want to double click on a product name and get a new form (popup) that
looks identical to the form they just doubled clicked on but already
filtered to only the records that had the same product name.

Example:
A form with a list of 1000 different cars.
Double click on Toyato Camery and get a popup form that is a list of only 4
Toyota Camerys (each a different color).
Forms are built
Quires are built
But the double click action on the field name Opens the proper form but NOT
filtered.

What is wrong with my code (or approach)?

Private Sub Description_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmProductsPopUp"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
stLinkCriteria = "[Description]=" & Me![Description]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Thanks in advance,
D
 
K

Klatuu

stLinkCriteria = "[Description]=" & Me![Description]
Should be:
stLinkCriteria = "[Description]= '" & Me![Description] & "'"

I am sure Description is a text field, so it needs the correct delimiters.

This line:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Should be rewritten. I don't even know what it does. I would have to go to
a lot of trouble just to figure it out. This code was once all that was
available in Access, but it has long been superceded. It is only there to
support backwards compatibility.
 
J

John W. Vinson

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Should be rewritten. I don't even know what it does. I would have to go to
a lot of trouble just to figure it out. This code was once all that was
available in Access, but it has long been superceded. It is only there to
support backwards compatibility.

Looks familiar... <g>

If Me.Dirty Then Me.Dirty = False

is an appropriate substitute. It just saves the record.

John W. Vinson [MVP]
 
K

Klatuu

Thanks, John. I thought so, but my poor ol' brain can't remember all that
stuff from way back when. Maybe that was why I preferred FoxPro back then :)
 

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