Consulting

Results 1 to 4 of 4

Thread: Copying textbox to another form

  1. #1
    VBAX Newbie
    Joined
    Jul 2008
    Posts
    2
    Location

    Copying textbox to another form

    Ok. Im a bit of a newb and this may have been covered many times before, but I'm having trouble finding it!

    I've got "Form1" which has a textbox (txtOutput) and a button (cmdOpen) which opens "Form2". This has a textbox (txtInput) which when completed I would like to be copied to txtOutput on Form1 when cmdCopy is pressed on Form2.

    I tried
    [Forms]![Form1]![txtOutput].Text = Me.txtInput.Text
    which produced the error saying I cant reference a property unless it has focus. So I added
    [Forms]![Form1]![txtOutput].SetFocus
    to the start but am still getting the same error.

    Am I missing something simple?

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,297
    Location
    Forms![Form1]![txtOutput] = Me.txtInput

    Should do it.
    But can I ask why you are repeating data?

  3. #3
    VBAX Newbie
    Joined
    Jul 2008
    Posts
    2
    Location
    That worked a treat. Thanks. What exactly was I doing wrong?

    Basically Form2 will build a fault code from dropdown boxes which when complete copies to Form1.

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,297
    Location
    You had the Forms part in Brackets and also you were using .text which is a field property.

    You could have used .value perhaps instead.
    I still don't understand why you are copying to Form1 why not have the Combo on Form1 as well?

Posting Permissions

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