Trinitrotoluene
Trinitrotoluene

Reputation: 1458

Function Error Object Required 800a01a8

I'm relatively new to functions and classes so not too sure if this is a beginners mistake. I'm getting:

Microsoft VBScript runtime error '800a01a8' 

Object required: 'EngineerNote(...)' 

/backup-check/backup_frontendlist_import_NEW.asp, line 76 

Line 76 is:

Set NoteArray=EngineerNote(company, servername, backupsolution)

The three variables I'm passing are all strings. All the function and class is set in:

Class EngineerNoteClass
public note
public notesubmitdate
End Class

Function EngineerNote(Company, ServerName, Solution)
Set RecordSet = Server.CreateObject("ADODB.Recordset")
RecordSetSQLString = "SELECT note, submitdate FROM tbl_BackupChecks_AuditInformation WHERE Company='" & company & "' AND ServerName='" & servername & "' AND Solution='" & solution & "' ORDER BY submitdate desc;"
RecordSet.Open RecordSetSQLString, DatabaseConnection
If Recordset.EOF Then
'Do Nothing
Else
Dim NoteResults
Set NoteResults = new EngineerNoteClass
noteresults.note = RecordSet("note")
noteresults.notesubmitdate = RecordSet("submitdate")
Set Engineernote = NoteResults
End If
Recordset.Close
End Function

Upvotes: 2

Views: 6005

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200193

Most likely your database query didn't return any results. You only set the return value of your function when the recordset isn't at EOF:

If Recordset.EOF Then
  'Do Nothing
Else
  ...
  Set Engineernote = NoteResults
End If

Setting the return value to Nothing (or to an empty EngineerNoteClass object) in the Then branch should make the error go away:

If Recordset.EOF Then
  Set EngineerNote = Nothing
Else
  ...
  Set Engineernote = NoteResults
End If

Make sure you handle the returned value/object appropriately in the rest of your script.

Upvotes: 5

Related Questions