D
doyle60
The following code works. It opens a form and goes to the
corresponding record if one exists (where CompPOID = CompPOID). The
code is built from the wizard's code but is augmented by me so it
doesn't filter the form it goes to. (I always hated the fact that the
wizard does that.) Anyway, the annoying thing is that it simply goes
to the first record if there is no link, that is, when the form being
opened does not have a corresponding CompPOID. I'd rather it go to a
new record. How can I amend the code to do that?
Here is the code:
___________________________________
On Error GoTo Err_Command5425_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim rsFind As Recordset
stDocName = "CompPOfrm"
stLinkCriteria = "[CompPOID]=" & Me![CompPOID]
DoCmd.OpenForm stDocName
Set rsFind = Forms(stDocName).RecordsetClone
rsFind.FindFirst stLinkCriteria
Forms(stDocName).Bookmark = rsFind.Bookmark
Exit_Command5425_Click:
Exit Sub
Err_Command5425_Click:
MsgBox Err.Description
Resume Exit_Command5425_Click
___________________________________
Thanks,
Matt
corresponding record if one exists (where CompPOID = CompPOID). The
code is built from the wizard's code but is augmented by me so it
doesn't filter the form it goes to. (I always hated the fact that the
wizard does that.) Anyway, the annoying thing is that it simply goes
to the first record if there is no link, that is, when the form being
opened does not have a corresponding CompPOID. I'd rather it go to a
new record. How can I amend the code to do that?
Here is the code:
___________________________________
On Error GoTo Err_Command5425_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim rsFind As Recordset
stDocName = "CompPOfrm"
stLinkCriteria = "[CompPOID]=" & Me![CompPOID]
DoCmd.OpenForm stDocName
Set rsFind = Forms(stDocName).RecordsetClone
rsFind.FindFirst stLinkCriteria
Forms(stDocName).Bookmark = rsFind.Bookmark
Exit_Command5425_Click:
Exit Sub
Err_Command5425_Click:
MsgBox Err.Description
Resume Exit_Command5425_Click
___________________________________
Thanks,
Matt