Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Label's Caption in Subform 1

Status
Not open for further replies.

jcmv007

Technical User
Nov 1, 2001
88
US
Using Windows XP sp1 and MsAccess 2002

I would like to change a Label's caption, which is on a subform, when the user changes the value in a combo box on a the main form. How can I do this? here is the code I'm using:

Code:
Private Sub cboMes_AfterUpdate()
    Dim stMesAb As String
    Dim sttitle1 As String
    
    stMesAb = Me.cboMes.Column(2) 'Incializa variable con mes abreviado
    
    If Me.fraFechaInfo = 1 Then     'Año a la fecha
        Me.txtMesD = 1
        Me.txtMesH = Month(dateFinDeMes)
        
    sttitle1 = getTitle(1, stMesAb)
    
    Forms!frmResumenGastos!Resumen.Controls.lblVarAnoAnt.Caption = sttitle1
    'Forms!frmResumenGastos!fsfrGastosPresup_AnoActual_Y_Anterior.Controls.lblVarAnoAnt.Caption = sttitle1
        
    Else                            'Mes especifico
        Me.txtMesD = Month(dateFecha)
        Me.txtMesH = Month(dateFinDeMes)
    End If
        Me.Resumen.Requery
End Sub
 
If your mainform is frmMain and your subform is frmMainSubform, and the name of the label control is lblYourLabel, then the following syntax will change the label's caption:

Forms!frmMain!frmMainSubform.Form!lblYourLabel.Caption = "New Label Caption"

Adapt your code according to this syntax.




Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Steve,

Thanks for your help! Here is how I finally solved it:

Code:
Forms!frmMain.frmMainSubfrom.Form!lblVarAnoAnt.Caption = sttitle1

And have a Star for your help! :)


James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top