Link to home
Start Free TrialLog in
Avatar of ShehzadMunir
ShehzadMunir

asked on

How to Unload the Label Control

Situation is that there is a form on which I select the Invoice No. FOr that Invoice No, there exists multiple Referance No in the database. Whenever user selects the Invoice No I display the Related Referance No by using the lable control array as follows:
'------------------------------------------------------
'This procedure accepts a parameter named strValue
'Which is the value to be displayed in the caption
'of the label control array
'------------------------------------------------------
Private Sub AddControlsAtRunTime(strValue As String)
    Dim I As Integer
    I = Me.lblReferenceNo.UBound
    If I = 0 And Trim(Me.lblReferenceNo(I).Caption) = "0" Then
        Me.lblReferenceNo(I).Caption = Trim(strValue)
    Else
        Load Me.lblReferenceNo(I + 1)
        Me.lblReferenceNo(I + 1).Visible = True
        Me.lblReferenceNo(I + 1).Caption = Trim(strValue)
        Me.lblReferenceNo(I + 1).Top = Me.lblReferenceNo(I).Top + Me.lblReferenceNo(I).Height '+ 60
        Me.lblReferenceNo(I + 1).Left = Me.lblReferenceNo(I).Left
    End If
End Sub

'--------------------------------------------------
'-------------------------------------------------

But when I need to change the Invoice No then I need to initialixe the label control array, i.e I would need to unload the label controls created at run by using the following procedure
'----------------------------------------------
Private Sub RemoveControlsAtRunTime()
    Dim I As Integer
    Dim J As Integer
    I = Me.lblReferenceNo.UBound
    If I > 0 Then
        For J = I To 1 Step -1
            Unload lblReferenceNo(J)
        Next J
    End If
End Sub
'--------------------------------------------  


But in this procedure the statment
"Unload lblReferenceNo(J)"

gives me an error

Run time error '365'
Unable to unload witrhin this context.


So while unloading I come across this error.

Can any body tell me about this arror.
ASKER CERTIFIED SOLUTION
Avatar of andyclap
andyclap
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Netminder
Netminder

There has been no activity in this question in quite some time, and it looks like it has been abandoned. As part of our ongoing mission to clean up the topic areas, a Moderator will finalize this question within the next seven (7) days. At that time, either I or one of the other Moderators will force/accept the comment of andyclap.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.

ShehzadMunir,

Some of these questions have been open for some time. Please resolve them appropriately as soon as possible.

https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20090669
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20100224
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20137180
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20154981
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20230974
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20239948
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20243913
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20193587
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20184112

Thanks,

Netminder
Community Support Moderator
Experts Exchange