On my form I use a double click procedure on a field [rePo] to open another form that contains the matching value using the code below.
Private Sub rePO_DblClick(Cancel As Integer)
On Error GoTo Err_rePO_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSalesOrder"
stLinkCriteria = "[PO]=" & "'" & Me![rePO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_rePO_DblClick:
Exit Sub
Err_rePO_DblClick:
MsgBox Err.Description
Resume Exit_rePO_DblClick
End Sub
If a record exists with the matching reference it is displayed.
If no record is found with the matching reference data a new blank record is created. (not what I want)
Access 2000 does not see this as an error, but I do.
How would I check that the record first exists, if not prevent a new record from being created when the reference is not matched, and inform the user of such?
Thanks, Just trying to understand error handling
UncleG
Private Sub rePO_DblClick(Cancel As Integer)
On Error GoTo Err_rePO_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSalesOrder"
stLinkCriteria = "[PO]=" & "'" & Me![rePO] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_rePO_DblClick:
Exit Sub
Err_rePO_DblClick:
MsgBox Err.Description
Resume Exit_rePO_DblClick
End Sub
If a record exists with the matching reference it is displayed.
If no record is found with the matching reference data a new blank record is created. (not what I want)
Access 2000 does not see this as an error, but I do.
How would I check that the record first exists, if not prevent a new record from being created when the reference is not matched, and inform the user of such?
Thanks, Just trying to understand error handling
UncleG