Error Trap Not Working - 'Object Required'

Jemmo

Registered User.
Local time
Today, 11:35
Joined
Jul 28, 2008
Messages
82
I want to put an IF THEN ELSE statement into some sode so that if an sql statement returns an empty recordset, the code exits (without doing the looping data crunch).

Having had a look around I tried;

If Cupidrst Is Null Then
Me![chkPBSEAwaitAdopts] = 1
MsgBox "PBSE Await Adopts Complete"
Exit Sub
End If

Cupidrst.MoveFirst
etc

But this is giving me a Run-time error '424': Object Required error.

Any ideas what is wrong with this?
 
Cupidrst is a recordset based on a sql statement.
It just gets a DISTINCT list of Cupids (Supplier Id's).

It all works as it should without this trap but in testing I came across a situation whereby there is a possibility of an empty recordset being produced when used in production, so I thought I better put something in to cater for that scenario.
 
Simple Software Solutions

After you have established the recordset using

Set CupidRst = CurerntDb.OpenRecordset(Cupid)

use

Code:
If CupidRst.OEF or CupidRst.BOF Then

... no records returned

Else

... records found

End If

CupidRst.Close

Set CupidRst = Nothing
 
Thgat should probably be:

Code:
If CupidRst.EOF AND CupidRst.BOF Then
 
Simple Software Solutions

I stand corrected, it is Friday afternoon and I am looking forward to going to the Races tomorrow.
 
Yeah Fridays can be hard that way. I've got a script that automates an FTP job, and redirects the output into a text file, so if it stuffs up, I can see what went wrong. Anyway, said FTP job isn't working, so I take a look at this text file to see what went wrong.

$ more ftp.log
Permission denied.

WTF?
$ cat ftp.log
Permission denied.

So I spend the best part of an hour trying to work out why Linux won't let me read this damned file, checking permissions, using sudo. Lets me delete it, but won't let me read it. So, I look at it in a hex editor:

$hexdump -c ftp.log
0000000 P e r m i s s i o n d e n i e
0000010 d . \n
0000013

The contents of the file are the words 'Permission denied.'
*thud*
 
Cupidrst.EOF

Yes thanks - that worked.

Many thanks
 

Users who are viewing this thread

Back
Top Bottom