Object variable not set using 6.0, works in 6.5

Hi, in the switcher Mail form I of the mail6ex.ntf template i modified it and added a field that basically displays the size of the database. The code is as follows:

Sub Onload(Source As Notesuidocument)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim ws As New NotesUIWorkspace

Dim uidoc As notesuidocument



Dim used As Double

Dim empty As Double

Dim size As Double

Dim emptymem As Double



Set uidoc = ws.Currentdocument 

Set doc = uidoc.document

Set db = session.CurrentDatabase



size = db.Size

size  = Round(size / 1000000,0)

used = db.PercentUsed

empty = 100 - used

emptymem = Round(empty/100 * size,2)

size = Round(size - emptymem,2)



doc.ds = Cstr(size) & " MB"

If size > 499 Then

	doc.d3 = "Cleanup Mail"

Else

	doc.d3 = ""

End If	

End Sub

It works in 6.5 + but in the 6.0 client when you open the db I get an Object variable not set on this line:

Set doc = uidoc.document

I tried other events but say thing all the time.

I also have a ‘refresh’ button with the exact same code on the form, and it works on both 6.0 6.5. Its just when opening the database in 6.0 that it gives me the Object Variable Not Set message.

My guess is it just doesn’t work in 6.0, but if anyone can offer and help it would be much appreciated.

Thanks

ST

Subject: Possible workaround Try:

Set uidoc = Source	Set doc = Source.Document

Subject: RE: Possible workaround Try:

Thank-you Bill. It worked. Can you explain to me why? Whats special about using

Set uidoc = Source

Set doc = Source.Document 

instead of

Set uidoc = ws.Currentdocument 

Set doc = uidoc.document

???

Thanks

ST

Subject: RE: Possible workaround Try:

As I understand it, this event fires before the uidocument object actually becomes the CurrentDocument in the workspace. Source, on the other hand, already comes with a free handle, so timing isn’t an issue.