Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Thanked 0 Times in 0 Posts

    retrieving data from sybform (Access 2000)

    Can i retrieve the data from a control in the subform?

    How can i make a control on the main form obtain the same value as the control in the subform? My sybforms are not connected,
    but sometimes i want the value of the subform to be equal to the value in the main form, with the help of the following code:

    Sub Toggle(Click)
    Forms![MainForm].LastName.Value = [Forms]![MainForm]![Subform].[Form]![LastName]
    End Sub

    However the control in the main form does not receive the value form the subform.Is it possible at all to transfer the data ?

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Arlington, Virginia, USA
    Thanked 3 Times in 3 Posts

    Re: retrieving data from Subform (Access 2000)

    Recommend use this syntax (assuming code is being called from main form):
    <pre>Me.LastName = Me.subfrmSubform![LastName]</pre>

    In above example, "subfrmSubform" is name of subform control on main form, not name of subform itself (though it is possible the two may be the same).

    If you are updating main form based on some event taking place on subform, and are calling code from subform, you can use this syntax:
    <pre>Me.Parent.LastName = Me.LastName</pre>


  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: retrieving data from sybform (Access 2000)

    I hope your subform isn't actually named Subform, because it's a very bad idea to give an object a name that is a reserved word and Access actually has a subform object, i.e., instant reserved word. If it *is* named Subform, change it before it bites you.

    Also keep in mind that the only value you can retrieve like this is the value in the current record in the subform. Your code is setting the value in the main form control to the value in the subform, but you said "sometimes i want the value of the subform to be equal to the value in the main form." That isn't quite the same thing as wanting the main form value to be equal to the subform value. I have a feeling you may be building yourself some data problems with this approach unless you can clarify exactly what you want to do under any and all circumstances.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts