winxmun
11-01-2015, 07:08 AM
Hi all, pardon me as I am not good in VBA. I am converting my current Access 2003 files to 2010. 1st error hit is cant run "rst.nomatch". Below is my code. Would appreciate any help. Thank you!
Private Sub Testing_Click()
On Error GoTo Err_Testing_Click
Dim rst As Recordset
Dim wsp As Workspace
Dim dbs As Database
Set wsp = DBEngine.Workspaces(0)
Set dbs = wsp.OpenDatabase("D:\File A.accdb")
Set rst = dbs.OpenRecordset("Table1", dbOpenTable)
With rst
.Index = "PrimaryKey"
.Seek "=", Me!Serial_No
If .NoMatch Then
Call AddRecord
End If
End With
rst.Close
Set wsp = Nothing
Exit_Testing_Click:
Exit Sub
Err_Testing_Click:
MsgBox Err.Description
Resume Exit_Testing_Click
End Sub
Private Sub Testing_Click()
On Error GoTo Err_Testing_Click
Dim rst As Recordset
Dim wsp As Workspace
Dim dbs As Database
Set wsp = DBEngine.Workspaces(0)
Set dbs = wsp.OpenDatabase("D:\File A.accdb")
Set rst = dbs.OpenRecordset("Table1", dbOpenTable)
With rst
.Index = "PrimaryKey"
.Seek "=", Me!Serial_No
If .NoMatch Then
Call AddRecord
End If
End With
rst.Close
Set wsp = Nothing
Exit_Testing_Click:
Exit Sub
Err_Testing_Click:
MsgBox Err.Description
Resume Exit_Testing_Click
End Sub