Createcontrol

Nizar

Registered User.
Local time
Today, 15:23
Joined
Oct 21, 2007
Messages
41
Nice day for all of you,

I have a problem using Createcontrol method with Vba. In fact, i would like to add to my form a label once a desired value is selected from a combobox.

here is my code, i didn't match where is the problem exactly:

Sub NewControls()
Dim iwb As Control
Set iwb = CreateControl(Me.Form, acLabel, , Me.Carrier.Name, 100, 100)
End Sub

Private Sub Carrier_AfterUpdate()
If Me.Carrier.Column(1) = "FedEx" Then
NewControls
End If
End Sub


Thanks in Advance
 
Once you create the label, it'll be there on any record! The normal way this is handled, rather than creating a label, is to create the label then control its visibility. Create the label (what you place as its caption doesn't matter) then in Properties, set its initial visibilty to No. Then use this code.

Code:
Private Sub Carrier_AfterUpdate()
 If Me.Carrier.Column(1) = "FedEx" Then
  YourLabel.Caption = Me.Carrier.Column(1)
  YourLabel.Visible = True
 Else
  YourLabel.Visible = False
 End If
End Sub

Private Sub Form_Current()
 If Me.Carrier.Column(1) = "FedEx" Then
  YourLabel.Caption = Me.Carrier.Column(1)  
  YourLabel.Visible = True
 Else
  YourLabel.Visible = False
 End If
End Sub

I think this will do the job for you.
 
Hi missinglinq ,

thanks very much for your help, I tried before with invisibility property but i failed. With your code, it is working :D million thanks again,

Have a nice day,
 

Users who are viewing this thread

Back
Top Bottom