How to change caption on a sub from text on main form 
Author Message
 How to change caption on a sub from text on main form

How do I change a caption for a field on a subform from a control on the main
form?  For example, on the main form I have a control called Misc1Name (this is
bound) and on the subform I have a field Misc1 and a label Misc1Label.  When I
enter "Lace #" (no quotes) in Misc1Name, I want the caption for Misc1Label to
change on the subform to "Lace #" (no quotes).

I put the following in the OnCurrent of the subform:

Me.Misc1Label.Caption = Forms!ENTRYFORM2!Misc1Name

This worked except when I went to a record with a null value for Misc1Name, it
gave me an invalid use of null error.

So then, I entered this:

If Forms!ENTRYFORM2!Misc1Name Is Not Null Then
Me.Misc1Label.Caption = Forms!ENTRYFORM2!Misc1Name
End If

Now I get an Object Required error.

What do I do?  Thanks in advance,

Doyle60



Tue, 28 Nov 2000 03:00:00 GMT  
 How to change caption on a sub from text on main form

Hi Doyle60,

Try this method

Private Sub Form_Current()
    With Me!Misc1Label
        If Not IsNull(Me.Parent!Misc1Name) Then
            .Caption = Me.Parent!Misc1Name
        Else
            .Caption = vbNullString
        End If
    End With
End Sub

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------


:How do I change a caption for a field on a subform from a control on the
main
:form?  For example, on the main form I have a control called Misc1Name
(this is
:bound) and on the subform I have a field Misc1 and a label Misc1Label.
When I
:enter "Lace #" (no quotes) in Misc1Name, I want the caption for Misc1Label
to
:change on the subform to "Lace #" (no quotes).
:
:I put the following in the OnCurrent of the subform:
:
:Me.Misc1Label.Caption = Forms!ENTRYFORM2!Misc1Name
:
:This worked except when I went to a record with a null value for Misc1Name,
it
:gave me an invalid use of null error.
:
:So then, I entered this:
:
:If Forms!ENTRYFORM2!Misc1Name Is Not Null Then
:Me.Misc1Label.Caption = Forms!ENTRYFORM2!Misc1Name
:End If
:
:Now I get an Object Required error.
:
:What do I do?  Thanks in advance,
:
:Doyle60
:
:
:
:
:



Tue, 28 Nov 2000 03:00:00 GMT  
 How to change caption on a sub from text on main form

Try This:

(Substitute SubFormName with your subform name)

If Not IsNull(Me!Misc1Name) Then
  Me!SubFormName.Form!Misc1Label.Caption = Me!Misc1Name
End If

HTH

Quote:

> How do I change a caption for a field on a subform from a control on the main
> form?  For example, on the main form I have a control called Misc1Name (this is
> bound) and on the subform I have a field Misc1 and a label Misc1Label.  When I
> enter "Lace #" (no quotes) in Misc1Name, I want the caption for Misc1Label to
> change on the subform to "Lace #" (no quotes).

> I put the following in the OnCurrent of the subform:

> Me.Misc1Label.Caption = Forms!ENTRYFORM2!Misc1Name

> This worked except when I went to a record with a null value for Misc1Name, it
> gave me an invalid use of null error.

> So then, I entered this:

> If Forms!ENTRYFORM2!Misc1Name Is Not Null Then
> Me.Misc1Label.Caption = Forms!ENTRYFORM2!Misc1Name
> End If

> Now I get an Object Required error.

> What do I do?  Thanks in advance,

> Doyle60



Tue, 28 Nov 2000 03:00:00 GMT  
 How to change caption on a sub from text on main form

Thanks Jim and Dev.

Dev's method worked.  I think my method and Jim's method failed because the
subform control name and subform name are the same.

But Jim's method came in handy on a simalar but different issue:  When I wanted
the label to get its info from data in the subform's own Control Source.

Thanks to both,

Doyle60



Tue, 28 Nov 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. create main form and Sub Form

2. create Main Form Sub form in VB6

3. sub report changes its source stored procedure to main report's stored procedure

4. Showing a form from within Sub Main.

5. changing stuff in your main form from another form

6. Invock a dll that has sub Main(), instead of a form as entry point

7. trying to start a form, from a MAIN sub in a module

8. Sub Main(): keep app open after showing form?

9. how to change properties of the main form from a another form

10. Opening a form from a Mobule Sub Main

11. FindRecord - link main and sub forms with else

12. Good Main/Sub form Software

 

 
Powered by phpBB® Forum Software