Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This code crashes in access 2007

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hi Guys,
Dont know if it was a good idea to change from Access 2003 to Access 2007. The following code works ok in Access 2003, but crashes the database in access 2007
Code:
Private Sub cboTax_AfterUpdate()
On Error Resume Next

    Dim rs As ADODB.Recordset
    Dim strSql As String
    
     cboTax.SetFocus
    If cboTax.Value > 0 Then
        strSql = "SELECT * FROM [tblTaxType-Accts] WHERE TaxType = " & cboTax.Value
    
        Set rs = CreateObject("ADODB.Recordset")
        rs.CursorType = adOpenKeyset
        rs.LockType = adLockOptimistic
        rs.Open strSql, CurrentProject.Connection
        
        If rs.State = 1 Then
            If Not rs.BOF Then
               
                Me.Tax = rs("type")
                Me.TaxPrefix = rs("Prefix")

            End If
            rs.Close
        End If
        Set rs = Nothing
    End If
End Sub

Could someone give me some clues as to why, and if the gurus could tell whether to stay with access 2003.

Many Thanks,

Integrity

 
what happens if you comment out the On Error instruction ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hello PIV

I found the source of the problem. I had MS Office2010 installed as well. When I uninstalled this I had no more issues with the above code crashing the database.
It seems that access 2010 and 20007 can't coincide on the same computer.

Integrity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top