Suppress Errors

nichojo

New member
Local time
Today, 07:32
Joined
Oct 26, 2010
Messages
9
I have created a very complex form that displays query results as drop downs and does some basic data manipulation (not creation) as a result. When I close the form I get an error related to the index or primary key not found and I would like to suppress this error as it isn't actually relevant and I honestly don't even know which primary key it is even talking about. Is this possible?

Also, is there a way to catch and display a custom "record not found" error?

Thanks!
 
Try:
Code:
DoCmd.SetWarnings False
Then to turn them back on again;
Code:
DoCmd.SetWarnings True
 
Try:
Code:
DoCmd.SetWarnings False
Then to turn them back on again;
Code:
DoCmd.SetWarnings True

Thanks for the quick reply. However that doesn't stop the error - I put it in the onload of the form.
 
Can you post the code that is giving you the error?
 
This is the logic for populating a combo box. Even if I don't execute the rest of the logic and just simply populate a box, I get the error so I think its in here:

Let's see here:

Code:
    Dim dbCurr As DAO.Database
    Dim rs As DAO.Recordset
    Dim SQL As String

    With Me.cmbRole
        For lListIndex = .ListCount - 1 To 0 Step -1
            .RemoveItem (lListIndex)
        Next lListIndex
    End With

    SQL = "SELECT DISTINCT Tb_SOP_Role_History.SOP_Role , Tb_SOP_Role_History.SOP_Number " & _
            "FROM Tb_SOP_Role_History " & _
            "WHERE Tb_SOP_Role_History.Associate_ID = '" & Me![Associate_ID].Value & "';"
            
    Set dbCurr = CurrentDb
    Set rs = dbCurr.OpenRecordset(SQL)
  
    Do While Not rs.EOF
     cmbRole.AddItem (rs.Fields(0) & ";" & rs.Fields(1))
     rs.MoveNext
    Loop
    
    rs.Close
    dbCurr.Close
 
you need to use the form's error event to intercept and disregard the error

however, i would be inclined to establish the exact cause of the error, rather than just dismiss it - at leasst you get a better understanding of access, that way.
 

Users who are viewing this thread

Back
Top Bottom