Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2006
    Posts
    59

    Arrow Unanswered: copy form's field to another textbox

    hi
    my question is that how can i copy the data entered in one text box to another. for eg i have two text boxes, from date and to date. what i want to do is when user enters date in from date texbox and presses enters it should get copied in the to date text box.

    secondly do cursors work with access.. if no then how can i store multiple queries in variables and call then as desired

    any help would be appreciated
    thanks

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    In the first text box's property sheet, you'll see an event call "After Update". Set that to [Event Procedure] and click the elipsis (...) on the right side to got into the code view showing the "After_Update" event.

    Assuming your text boxes are txtFromDate and txtToDate, the code looks like: Me.txtToDate = Me.txtFromDate

    (technically, it should be: Me.txtToDate.Value = Me.txtFromDate.Value, but Value is the assumed property of a text box).

    As for the second question, you can create and save queries and then call them to recordset variables as needed. There are other methods, but that most closely matches your question from what I can tell. I'm sure others will comment.

    tc

  3. #3
    Join Date
    Feb 2006
    Posts
    59
    thanks alot tcace

  4. #4
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Quote Originally Posted by tcace
    In the first text box's property sheet, you'll see an event call "After Update". Set that to [Event Procedure] and click the elipsis (...) on the right side to got into the code view showing the "After_Update" event.

    Assuming your text boxes are txtFromDate and txtToDate, the code looks like: Me.txtToDate = Me.txtFromDate

    (technically, it should be: Me.txtToDate.Value = Me.txtFromDate.Value, but Value is the assumed property of a text box).

    As for the second question, you can create and save queries and then call them to recordset variables as needed. There are other methods, but that most closely matches your question from what I can tell. I'm sure others will comment.

    tc
    Hello Tcase;

    Reference the above... how would that be done if Data_A is on Form_A and Data_B is on Form_B and you wanted to copy Data_A to Data_B after Form_A closes. Is that possible?

    Thanks...
    Larry

  5. #5
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    It certainly is possible. You just need to tell the software which collection the object is in.

    The form is a collection of objects, the text box being one of those objects. You'll notice that my example used the word ME in it. ME is shorthand for "Current Form".

    I could rewrite the same line of code to be:
    Forms("Form2").txtToDate = Forms("Form1").txtFromDate

    but I assume we're in Form1, so I'd write:
    Forms("Form2").txtToDate = Me.txtFromDate

    There are numerous ways to call out objects, collections, properties, etc. and there is a lot of material out there that explains and provide examples, starting with the help file.

    Good luck,
    tc

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    that should work providing both forms are open at the same time. you can only reference a form or reports objects providing those forms & reports are open.

    you could move the data when FormA closes, but not after it closes (put some ocde int he forms on close event that transfers the data to form b.

    failing that you could transfer the data to an intermediate form, or module (although that would be frowned on as using global varaiables for seemingly no significant reason). As an alternative you could psot the values to a file or table and pick them up as required from that source.
    HTH
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Aug 2005
    Location
    Delaware
    Posts
    139
    Thanks tc and HTH... I'll play around with it and see if I can get it to work. I do close the Form_A prior to opening Form_B, but I guess I could leave it open until the transfer is complete, then close it after say control #1 has focus, right?

    Larry

  8. #8
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    sure - you can do anything you want with a little code

  9. #9
    Join Date
    Jun 2014
    Posts
    10
    Quote Originally Posted by tcace View Post
    It certainly is possible. You just need to tell the software which collection the object is in.

    The form is a collection of objects, the text box being one of those objects. You'll notice that my example used the word ME in it. ME is shorthand for "Current Form".

    I could rewrite the same line of code to be:
    Forms("Form2").txtToDate = Forms("Form1").txtFromDate

    but I assume we're in Form1, so I'd write:
    Forms("Form2").txtToDate = Me.txtFromDate

    There are numerous ways to call out objects, collections, properties, etc. and there is a lot of material out there that explains and provide examples, starting with the help file.

    Good luck,
    tc
    Sorry to dig up an old post as my first post but this deals directly with what I need to do. Above the OP is attempting to duplicate the "Form 2" field using the data in "Form 1". What I am trying to do is duplicate the data in multiple field from "Form 1" into "Form 2". I hope I am clear enough as to my goal.

  10. #10
    Join Date
    Jun 2014
    Posts
    10
    Quote Originally Posted by tcace View Post
    In the first text box's property sheet, you'll see an event call "After Update". Set that to [Event Procedure] and click the elipsis (...) on the right side to got into the code view showing the "After_Update" event.

    Assuming your text boxes are txtFromDate and txtToDate, the code looks like: Me.txtToDate = Me.txtFromDate

    (technically, it should be: Me.txtToDate.Value = Me.txtFromDate.Value, but Value is the assumed property of a text box).

    As for the second question, you can create and save queries and then call them to recordset variables as needed. There are other methods, but that most closely matches your question from what I can tell. I'm sure others will comment.

    tc
    Sorry for digging up such and old post but this deals with what I am running in to. Above it is described how to link text boxes in forms. What I would like to do is not only duplicate one field in "Form 2" from "Form 1" but multiple fields from "Form 1" into one field in "Form 2"

    Thank you in advance for your help

Posting Permissions

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