Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003

    Question Unanswered: assign unbound txtbox with length of another

    I'm slowly learning and was wondering how i can make the value of a textbox on a form display how many charachters are in a different field on the form, updating after every keypress. I'm pretty dumb with code, but so far i made an onChange event procedure for the textbox to be counted, but I don't know VBA syntax too well. any help is appreciated

  2. #2
    Join Date
    Jul 2003
    First: don't count characters with an OnCount-Event; or did you check backspace, tab, every special key you can imagine?
    So it's better to use the Len(me.Textbox.value) function.

    Second, you put the value you get from this function into another textbox (or whatever) simply by:

    Me.Counterbox.value = len (me.Textbox.value)

    (Where Counterbox and Textbox are the names of your boxes, of course)

  3. #3
    Join Date
    Dec 2002
    Préverenges, Switzerland
    hi SubHugo: did you try your proposal?

    when i try to
    counterbox.value =
    in the textbox_Change event i trigger run-time error 2448 can't assign a value to this object

    also, in the textbox_Change event, a
    msgbox len(textbox.value)
    does NOT reflect the current length of the string (seems to be stuck on the len when the box last lost focus)

    ...because (???) you are still editing textbox.value


    (above experiments in A2K)

  4. #4
    Join Date
    Jul 2003
    No need to try it, i know that it works.
    If you want to use it with a box you are editing at the moment, you have to use the .text-property.

    Can you explain your first question? There's no obvious reason why you can't set the value of an unbound textbox.

Posting Permissions

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