Maintaining Different Values in the Same Control on a Continuous Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdamOnAccess
    New Member
    • Aug 2008
    • 99

    Maintaining Different Values in the Same Control on a Continuous Form

    This is something I've always had trouble with, and it comes up fairly frequently...

    I have a continous form with a single text field and next to this text field, I have a caption that maintains the number of characters the user can type into the text field before they reach maximum (the number decreases with every key stroke). It looks like this:

    Text In Field Here 18

    I use this function to keep count of the characters remaining in the text field.

    Code:
    Function pfnCalcCharactersRemainingInField(intMaxCharactersAllowed As Integer) As Integer
    'calculate how many characters you can enter before you reach intMaxCharactersAllowed
    
    Dim C As Control
    Set C = Screen.ActiveControl
    
    pfnCalcCharactersRemainingInField = intMaxCharactersAllowed - Len(C.Text)
        
    End Function
    This system works fine if I have a single field and caption on a single form.

    If I have a single field and caption on a continuous form, the caption on every line updates based on the current text field getting the data.

    How do I get the captions to display the correct character numbers for each line in a continuous form?

    Thanks,
    Adam
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    This is something I've always had trouble with, and it comes up fairly frequently..
    Sorry, Adam, but if the above is true, you must have been told that this is normal behavior in an unbond control on a Continuous or Datasheet View Form! Regardless of the number of times it arises, the answer is not going to change; the control has to be bound to be record-specific!. Changing the label to a textbox and having it bound to a field in the underlying table is the only way I see to get this to work in this scenario.

    To be honest, the type of field this kind of hack is usually associated with normally only appears on Single View Forms.

    Linq ;0)>

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      Linq is absolutely right of course. See Why Values in Unbound Form Controls do not Persist.

      It does help also, to refer to items by their proper names (I know you're quite new but I suspect you're getting to the stage now where using the correct terms will make a difference). Fields are items in a recordset (Table; QueryDef; etc). Controls are items defined on a form or report that are used to display the values of the underlying fields or other data. I've changed the title for you to reflect this.

      Comment

      • AdamOnAccess
        New Member
        • Aug 2008
        • 99

        #4
        Originally posted by missinglinq
        This is something I've always had trouble with, and it comes up fairly frequently..
        Sorry, Adam, but if the above is true, you must have been told that this is normal behavior in an unbond control on a Continuous or Datasheet View Form!
        Linq, it is true, I do run up against it occasionally, I just haven't bothered to ask about it before. I simply wanted to know how other people addressed it.

        NeoPa, thanks for the definitions and corrections. Yes, clearly, I'm new :)

        Thanks for the help.
        -Adam

        Comment

        Working...