Hello Access experts,
I have a company form on which I put a command button that opens a purchase order form.
The idea is that the company form creates a purchase order heading and opens the form on the new purchase order record.
My problem is that the openform command ignores the where clause.
In a previous post, someone told me to open aform without a where clause, and to reopen it with the where clause. But this does not work either.
The Purchase Order form invariably opens on the first record in the Table, and no matter what I try, never on the right record.
Here is the code:
Could it be that the record created in thsi code is somehow not available when I open the Purchase Order form?
Thanks in advance for good advice.
I have a company form on which I put a command button that opens a purchase order form.
The idea is that the company form creates a purchase order heading and opens the form on the new purchase order record.
My problem is that the openform command ignores the where clause.
In a previous post, someone told me to open aform without a where clause, and to reopen it with the where clause. But this does not work either.
The Purchase Order form invariably opens on the first record in the Table, and no matter what I try, never on the right record.
Here is the code:
Code:
'Create the Purchase Heading record
rstHead.AddNew
rstHead!PUDate = Now
rstHead!PUOrderNb = strRight
rstHead!PUCompID = Me.ID
rstHead!PUVat = defVat
rstHead!PuSent = 0
rstHead.Update
rstHead.Bookmark = rstHead.LastModified
MsgBox "Purchase Order Created"
DoCmd.RunCommand acCmdSaveRecord
strWhere = "[PUOrderNb] = " & strRight
If CurrentProject.AllForms("frmPurchase").IsLoaded Then
DoCmd.Close "frmPurchase"
End If
DoCmd.OpenForm "frmPurchase"
DoCmd.OpenForm "frmPurchase", , strWhere
Thanks in advance for good advice.