Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy data from one text box to another

Status
Not open for further replies.

stacyemma

IS-IT--Management
Jan 23, 2003
8
GB
I am having problems with something which is probably most the simplest of issues.
I have a form (frmmain) with a small subform (sbfattend). On frmmain I have a text box named txtdate and antoher on sbfatted named txtstartdate. I need a button on frmmain which when clicked copies the data from txtdate to txtstartdate.
Like i said probably an extreamly simply issue but it is evading me at present. Any help would be most appriciated.

Stacy
 
fairly easy i've done this for tracking dates of last worked and current date worked

onclick event:


me.txtstartdate = me.txtdate

:)

hope this helps Cruz'n and Booz'n always.
This post shows what little I do at work.
 
Except txtstartdate is on a sub-form, so...

private sub CommandButton_Click()

me.sbfattend.Form!txtstartdate = me.txtdate

end sub

 
Thanks for you help in this matter it worked a treat. But I have realised that the button needs to be on sbfattend rather than frmmain.
Now I thought that I could change the "me" entries to "frmmain" and it would still work, however it does not. I know that there must be something really basic here that I am missing out but cant seem to find it.
I would alo be really grateful if someone could explain to me what the "FORM!" part of the above code means. I did not learn VB from the basics up but in fact just learnt the bits that i needed to when issues arose. Therefore have missed most of the really basic thigns like how to locate a control in code!!!!
Many thanks
 
Ok - I've done it.
I had to put..
[Forms]![frmmain]![txtstartdate] = [Forms]![frmmain]![sbfattend]![txtdate]

Although it now works I would really like to know why/how it works. I did the same thing basically but without the brackets and excalmation marks and have no idea what the differnce is.

Stacy
 
OK, going back to an earlier question "if someone could explain to me what the "FORM!" part of the above code means", here's a quick primer in how referencing a subform works...

Your parent form ("me") has a collection of controls. These include text-boxes, list-boxes, etc. and a subform control.

From one perspective the subform control is just like any other control, in that you can reference and modify its properties. For instance, to change the width of a textbox, you would code:

me.txtCustomer.width = 2000

Likewise, to change the width of your subform control:

me.sfrmForm.width = 2000

However, from another perspective, the subform control is a container that contains another form. This other form also has its own collection of controls. The "Form!" element of the code says "the next part of the statement refers to a member of the control collection of the form that is contained in my subform control".

Hence,

me.SubForm.txtOrderID

is invalid because Access is expecting a reference to one of the properties of a subform control (Visible, Top, Width, Border Style, etc) and "txtOrderID" is not one of these properties.

However,

me.SubForm.Form!txtOrderID

is valid if the subform itself (as distinct from its container, the subform control) has a control called "txtOrderID" in its controls collections.

I'm not sure I've phrased this very clearly, so let me know if this is reading as gibberish ;)
 
Thanks nealv!!!

That explains it perfectly! No gibberish whatsoever!
The only thing that is confusing me now is why the above statement that I wrote works!

Thanks again
Stacy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top