I have two forms: customerinfo and customerorder
Once information is entered into the customer info field I want the user to be able to edit an existing order but only if an order already exists.
In the click event of the Edit Exisitng Order btn I have:
Private Sub btnEEO_Click()
On Error GoTo Err_btnEEO_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim RecordCount As Integer
RecordCount = DCount("CustomerID", "qryCustomerOrder")
If RecordCount > 0 Then
stDocName = "frmCustomerOrder"
stLinkCriteria = "[CustomerID]=" & "'" & Me![txtCustomerID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "No Order Exists"
End If
Exit_btnEEO_Click:
Exit Sub
Err_btnEEO_Click:
MsgBox Err.Description
Resume Exit_btnEEO_Click
End Sub
If an order doesn't already exist for the customer, the customer order form should not appear. For some reason my code is not working correctly but I cannot identify why.