....snagging this piece of code for me, and telling me why I get the message "The OpenForm action was cancelled"
____________________________________________________
Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click
Dim MyDb As DATABASE
Dim CustTable As Recordset
Dim TrackTable As Recordset
Dim LoanTable As Recordset
Dim IntroTable As Recordset
Dim FilterCriteria As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim CustId As Integer
Dim Code As String
Dim strMsg As String
Code = Left(Me![Surname], 6) & Right(Me![HomeTel], 4) ‘This creates a unique “Identifier”
Set MyDb = DBEngine.Workspaces(0).Databases(0)
If Me![Check] = False Then
Me![Check] = True
Set CustTable = MyDb.OpenRecordset("tblCustomer", DB_OPEN_DYNASET)
FilterCriteria = "[Identifier]='" + Code + "'"
CustTable.Filter = FilterCriteria
Set CustTable = CustTable.OpenRecordset()
If CustTable.EOF = False And CustTable.BOF = False Then
strMsg = MsgBox("These Details appear to be on the system already - Click Yes to View. No to Add Anyway.", vbYesNo)
If strMsg = vbYes Then
stDocName = "frmCustomerDetails"
stLinkCriteria = "[CustomerID]=" & "'" & CustTable![CustomerID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Click on Update Again to Add Record"
End If
End If
Else
‘Here it adds details to a couple of tables’
End If
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub
____________________________________________________
The code is supposed to check for duplicate entry. If it finds a duplicate it is supposed to open the detail form of the customer so that the user can decide whether to add the record or not. But it keeps getting the message about OpenForm being cancelled. I have deleted some of the code, but I am 99% certain the problem is not there, and wanted to keep this post as simple as possible.
I must be missing something stupid. Thanks
____________________________________________________
Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click
Dim MyDb As DATABASE
Dim CustTable As Recordset
Dim TrackTable As Recordset
Dim LoanTable As Recordset
Dim IntroTable As Recordset
Dim FilterCriteria As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim CustId As Integer
Dim Code As String
Dim strMsg As String
Code = Left(Me![Surname], 6) & Right(Me![HomeTel], 4) ‘This creates a unique “Identifier”
Set MyDb = DBEngine.Workspaces(0).Databases(0)
If Me![Check] = False Then
Me![Check] = True
Set CustTable = MyDb.OpenRecordset("tblCustomer", DB_OPEN_DYNASET)
FilterCriteria = "[Identifier]='" + Code + "'"
CustTable.Filter = FilterCriteria
Set CustTable = CustTable.OpenRecordset()
If CustTable.EOF = False And CustTable.BOF = False Then
strMsg = MsgBox("These Details appear to be on the system already - Click Yes to View. No to Add Anyway.", vbYesNo)
If strMsg = vbYes Then
stDocName = "frmCustomerDetails"
stLinkCriteria = "[CustomerID]=" & "'" & CustTable![CustomerID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Click on Update Again to Add Record"
End If
End If
Else
‘Here it adds details to a couple of tables’
End If
Exit_AddRecord_Click:
Exit Sub
Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click
End Sub
____________________________________________________
The code is supposed to check for duplicate entry. If it finds a duplicate it is supposed to open the detail form of the customer so that the user can decide whether to add the record or not. But it keeps getting the message about OpenForm being cancelled. I have deleted some of the code, but I am 99% certain the problem is not there, and wanted to keep this post as simple as possible.
I must be missing something stupid. Thanks