run-time error 13

G

Guest

I keep getting a "run-time error 13" when I run the following code, used to
update my table on the notinlist properity.

Dim DB As Database
Dim RS As Recordset
Dim Msg As String
Dim CR As String: CR = Chr$(13)


If NewData = "" Then Exit Sub


Msg = MsgBox("'" & NewData & "' is not in the list." & CR & CR & _
"Do you want to add it?", vbYesNo, "New Steel Size
Message")
If Msg = vbYes Then


Set DB = DBEngine.Workspaces(0).Databases(0)

Set RS = DB.OpenRecordset("tblSteelSize")
RS.AddNew

RS![SteelSize] = NewData
RS.Update


If Err Then

Response = DATA_ERRCONTINUE
Beep: MsgBox Error$, 48
MsgBox "Please try again."
Else

Response = DATA_ERRADDED
End If

End If
End Sub

Am I missing something? In my eyes this should work

Thanks

Mark
 
D

Douglas J. Steele

Try changing Dim RS As Recordset to Dim RS As DAO.Recordset

Recordset is an object in both the DAO and ADO models. Assuming you're using
Access 2000 or newer, your ADO reference is doubtlessly higher than your DAO
reference, so it gets preference. When you have both references, you'll find
that you'll need to "disambiguate" declarations for objects with the same
names that exist in the 2 models. The list of objects with the same names in
the 2 models is Connection, Error, Errors, Field, Fields, Parameter,
Parameters, Property, Properties and Recordset
 
D

Duane Hookom

Your Msg variable should be numeric, not string. There may be other errors
but this should get you a little further.
Dim Msg As Long
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top