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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Operation not supported by this type of object?

Status
Not open for further replies.

Gumbo78

Programmer
Feb 17, 2004
20
US
I am getting the error:
Operation not supported by this type of object


I only get a message box, access does not open the VB screen and highlight any code. This is my code:

Private Sub cmdsave_Click()
On Error GoTo Err_cmdsave_Click

Dim rs As DAO.Recordset
Dim db As DAO.Database

Set db = CurrentDb
Set rs = db.OpenRecordset("Inventory")

If [cmbinv].Value = "" Or [cmbinv].Value = Null Then
MsgBox "Please enter a valid Inventory number"
Else
rs.FindFirst "Inventory_Number = '" & [cmbinv].Value & "'"
If rs.NoMatch Then
DoCmd.SetWarnings False
With rs
.AddNew
!Inventory_Number = Me.cmbinv
!Size = Me.cmbsize
!Class = Me.cmbclass
!End_Con = Me.cmbendcon
!Model = Me.cmbmodel
!Manufacturer = Me.cmbmanufacturer
!Comments = Me.cmbcomments
!Status = Me.cmbstatus
!Part_Number = Me.cmbpn
!Serial_Number = Me.cmbsn
.Update
End With
DoCmd.SetWarnings True
Else
MsgBox "Duplicate Inventory Number, Please enter a valad Inventory Number."
End If
End If

db.Close
rs.Close

Exit_cmdsave_Click:
Exit Sub

Err_cmdsave_Click:
MsgBox Err.Description
Resume Exit_cmdsave_Click

End Sub

Can anyone see anything wrong with this? Since it is not highlighting anything I'm not sure what's wrong. At first I was getting an error trying to Dim rs as DAO.Recordset so I added in the DAO 3.6 reference. Now I'm not sure whats wrong. Any ideas?

-G78
 
It's a bit hard to read blue on blue background, but a guess is the "Chronology" of the tests, and the test for null:

[tt]If IsNull(Me![cmbinv].Value) or Me![cmbinv].Value = "" Then
MsgBox "Please enter a valid Inventory number"
Else[/tt]

Commenting the "On Error" line should throw you to the VBE on error.

Roy-Vidar
 
I got this working now thanks, it was a problem with trying to use rs.findfirst without opening the recordsoure as dynamic (I think) Ended up doing it a different way and its good now!

-G78
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top