stLinkCriteria Problem

James007

New member
Local time
Today, 01:25
Joined
Jun 8, 2012
Messages
8
I have a form that produces a datasheet that derives its information from a query. The query works fine giving the desired information.

In this datashee on "PurchaseOrderID" i have a On Dbl Click event that states this.

Private Sub PurchaseOrderID_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FrmPO_Received"
stLinkCriteria = "[ItemID]=" & Me.ItemID
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Now it works sometimes, but sometimes it pulls up a different "PurchaseOrderID". Is there a way to fix this. I thought maybe there would be a way to put two criteria, "ItemID" and "PurchaseOrderID".

Your help is much appreciated

:banghead:
 
Yes, you would need both unless one of the fields is the primary key of the record in the form being opened, which it likely is not, nor should it likely be so.

stLinkCriteria = "[ItemID]=" & Me.ItemID & " AND [PurchaseOrderID]= " & Me.PurchaseOrderID

(depending on if your field name in the form being opened is named PurchaseOrderID and the control on the form that this code is on is named PurchaseOrderID.
 
This worked out, no problems and the proper information is displaying on the form. I knew it needed just a little bit more of code. Thanks for your help.:D:D:D
 

Users who are viewing this thread

Back
Top Bottom