Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28

    Unanswered: Calling a textbox from a subform through code (not ControlSource)

    Hi,

    I am trying to call the value of a hidden textbox in the footer of a subform. I am trying to do it via code:


    Private Sub Form_Current()

    If IsNumeric(Form_RevisionTSubform.txtcount) Then

    Me.CounterP.Value = Form_RevisionTSubform.txtcount.Value

    Else

    Me.CounterP.Value = 0

    End If

    End Sub

    Bur regardless of how many records I have in the subform, it is returning 0. Can someone help? I want to do it via code, not through a control source, because I need to later compare that value to something else... When I use control source, the value returned is still always 0...

    Would appreciate your help!! Should I put it under Form_Current or something else?

    Thanks!

    Randa

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Not sure about the way you address the control, see: Forms: Refer to Form and Subform properties and controls
    Have a nice day!

  3. #3
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28
    I tried this with every way.. I actually had this page open.. The problem is that if I use controlsource of my CounterP textbox in the main form, it returns the right value.. I can see it correctly. However, if I put the same expression in the Default value or through a code, I always get a 0... If I refer to the CounterP in a code under Form_current, I also get a 0 (or error).. Strange..

  4. #4
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28
    Hi Sinndho,

    I think there is an issue with the delay.. The ControlSource of the CounterP textbox takes time to calculate. So in the meantime, form current executes the code and reads a blank value.. Or at least this is what I think is happening. I tried to put the code in CounterP_AfterUpdate but I still got nothing..

    Any advice?

  5. #5
    Join Date
    Feb 2014
    Location
    Pittsburgh, USA
    Posts
    28
    Ok, nope, not a delay..

Posting Permissions

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