Controls at runtime

06-06-2005, 12:11 PM
I load a form and on that form I put some controls at runtime. Everything works fine, until I load the form a second time. Then I get the error 360: Object already loaded.

What am I doing wrong?

Here is the code:
For nObjectCounter = 0 To UBound(ffFindFields)
nObjectTop = nObjectTop + 360
If nObjectCounter > 0 Then
Load frmFind.lblFind(nObjectCounter)
Load frmFind.txtFind(nObjectCounter)
End If
With frmFind.lblFind(nObjectCounter)
.Caption = ffFindFields(nObjectCounter).sFieldCaption
.Top = nObjectTop
.Visible = True
End With
With frmFind.txtFind(nObjectCounter)
.TabIndex = nObjectCounter
.Top = nObjectTop
.Visible = True
End With

06-06-2005, 12:19 PM
When you unload a form, the form instance isn't necessarily destroyed (nor are the control instances that it contains).

If it isn't possible for you to set the form instance to Nothing between loads, then unload the controls that you added from within the form's unload event.

06-06-2005, 12:29 PM
How do I set the instance of the form to Nothing?

I load the form with: Load frmFind

06-06-2005, 12:36 PM
Thank you. it works

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum