Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2008, 09:12 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Grab Values From List Box into Text Box

Ok...I have a MS Words form. I created a textbox in this form.

The other thing that I have is a popup "UserForm" with a listbox.

When an user select any one value from this listbox, I want that value to populate the "textbox".

Here are my codes:
Private Sub CommandButton1_Click()
ActiveDocument.FormFields("TextBox1").Result = Me.ListBox1.Text
Unload Me
End Sub
WHen I run this, I get an '5941' error message. Please advise what I am doing wrong.

Thank you.
Joe

 
Old June 19th, 2008, 09:19 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Joe

Can you try

Private Sub CommandButton1_Click()
ActiveDocument.FormFields("Text1").Result = Me.ListBox1.Text
Unload Me
End Sub

Word Formfields have Text1 instead of TextBox1

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old June 19th, 2008, 10:33 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried with "Text1" but still same error message. Somehow the codes is not applying what I have selected in the listbox into the textbox. Are my codes correct?






Similar Threads
Thread Thread Starter Forum Replies Last Post
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
How to get multiselect values from list box in jsp krishnamoorthymca JSP Basics 0 December 19th, 2006 02:13 AM
passing values from multiple list box tulincim Classic ASP Databases 22 October 6th, 2005 01:16 PM
passing values from multiple list box tulincim Javascript 4 September 14th, 2005 02:02 AM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.