none
how to transfer data from one cell to other such shift

    Frage

  • hi for all

    I have many textboxs in one form and each one have it's value how can I insert value to the first textbox in way the value of the first textbox transfer to scond texbox and scond transfer to the thired .....etc and the last will be deleted (such us shift to right )

    how can I make that

    Donnerstag, 27. Juni 2013 05:29

Alle Antworten

  • Wissam,

    I am not really sure what are you trying to accomplish, but it seems  you want to populate the value of textbox1 into textbox2 and etc

    In the after update event of text1...assign its value to textbox2 and clear textbox1 value.

    it should look something like this....

    ****************

    Private Sub Text1_afterupdate()

    Textbox2 = textbox1

    textbox1 = ""

    End sub

    ****************

    Repeat this process in hte afterupdate event for every textbox in your form. 

    Is this what you are looking for?  If not, let us know.

    • Als Antwort vorgeschlagen KCDW Donnerstag, 27. Juni 2013 14:33
    • Als Antwort markiert Dummy yoyoModerator Montag, 8. Juli 2013 07:59
    • Tag als Antwort aufgehoben wissam alshamy Samstag, 13. Juli 2013 17:28
    Donnerstag, 27. Juni 2013 11:49
  • Good Morning Wissam, La Mole,

    In addition to La Mole's comments,

    Tested the following in a Blank Form;

    1. Create Blank Form
    2. Add Textboxes Text0, Text2, Text4, Text6
    3. Set the .Visible Property on Text0 = NO
    4. In the OnLoad Event add Code Block A Below
    5. Set the Timer Interval to 1000
    6. Set the OnTimer Event to Code Block B Below

    Code Block A

    Private Sub Form_Load()
        Text0 = 1
        Text2 = 1
    End Sub
    

    Code Block B

    Private Sub Form_Timer()
        Text0 = Text0 + 1
        Text6 = Text4
        Text4 = Text2
        Text2 = Text0
    End Sub
    

    Now Compile the code and save the Form.

    Run the Form and watch the fields change where the value moves from one Field to the Next. These are unbound controls so will reset each time you open the Form. You can insert a value into any exposed field and it will fall back in line instantly since it is cascading from the hidden field.

    This was for informational purpose only.

    I am interested in understanding your needs in this question.


    Chris Ward

    Donnerstag, 27. Juni 2013 14:32
  • Noticed if you change La Mole's suggestion of using the AfterUpdate Event so that you use The AfterUpdate Event only in the First Textbox's CodeBlock that the first two fields will always be the Same. If you switch to the OnChange Event with a slight modification to the code to change the focus Then the Cascade will work to give a different value to Each.

    Code in the OnChange Event

    Private Sub Text0_Change()
        Text6.SetFocus
        Text0.SetFocus
        Text6 = Text4
        Text4 = Text2
        Text2 = Text0
    End Sub
    

    However the flaw to this is it will change with the First Character typed into the Field. This will not be a viable Solution.

    If you Remove the code parts to SetFocus it will allow multiple Characters typed before updating the first field but each subsequent Characrer added will cause the cascade to function out of sequence and the values will not populate correctly.

    Testing La Mole's solution with a code block in each TextBox's AfterUpdate Event indicates not completely viable as the Textboxes are updating programmatically and the AfterUpdate Event does not Fire subsequesntly. If you use a combo of the Two methods you can achieve your goal. I'll keep testing.


    Chris Ward

    Donnerstag, 27. Juni 2013 15:03
  • Im try the both way above but I can't solving the problem perfectly I have another Idea but I do't no the way to perform it if we are go to assign public variables to get the value of the textbox before it change and then using then second textbox after the first changed ....etc found away to do this scenario many regards for all
    Samstag, 13. Juli 2013 17:17
  • hi for all

    I have many textboxs in one form and each one have it's value how can I insert value to the first textbox in way the value of the first textbox transfer to scond texbox and scond transfer to the thired .....etc and the last will be deleted (such us shift to right )

    how can I make that

    Hi wissam,

    If you want to shift over 5 textboxes after entering a new value in textbox1, you could in the AfterUpdate event of textbox1 something like:

        textbox5 = textbox4
        textbox4 = textbox3
        textbox3 = textbox2
        textbox2 = textbox1.OldValue

    Is this what you mean?

    Imb.

    Samstag, 13. Juli 2013 18:58
  • thank U Mr Imb it may be good solution but I have two point - what it mean Oldvalue for textbox - what is you opinion by using local variables to couch old value the we will reused then again as describe above thanks for all
    Sonntag, 14. Juli 2013 12:55
  • thank U Mr Imb it may be good solution but I have two point - what it mean Oldvalue for textbox - what is you opinion by using local variables to couch old value the we will reused then again as describe above thanks for all

    Hi Wissam,

    When you update a textbox, its old (previous) value is still available through the property OldValue.

    You COULD use local variables to hold a couple of previous values, but you also can use a couple of textboxes to hold that previous values. Or even an array. But you can also use a table to store these values permanently.

    I do not know why you want to have these old values, nor what you want to do with them. And it is all dependent on the circumstances which solution would give better results.

    Imb.

    Sonntag, 14. Juli 2013 21:17