473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Copy listbox contents to another listbox

I have a form with a listbox. I want to open a new blank form and assign the same values to the blank form's listbox. What is the best way to go about doing this? I have a majority of the code configured. My problem is writing the proper syntax to assign the listbox in the new blank unsaved document "doc" the values from the first document's listbox.

Should I declare a temporary listbox to carry over the values to the next listbox?

My listbox is named IRABene_Main.ListBox1 in both documents and I can't seem to find a way to write doc.IRABene_Main.ListBox1and mean to update the blank form's listbox.

See the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub UpdateAdditionalAccount_Click()
  2. Dim appWord As Word.Application
  3.  
  4. Dim doc As Word.Document
  5.  
  6. Dim Name As String
  7. Dim SSN As String
  8. Dim bday As String
  9. Dim address As String
  10. Dim dayphone As String
  11. Dim branch As String
  12.  
  13. Name = Me.FormFields("name1").Result
  14. SSN = Me.FormFields("ssn").Result
  15. bday = Me.FormFields("bday").Result
  16. address = Me.FormFields("address").Result
  17. dayphone = Me.FormFields("dayphone").Result
  18. branch = Me.FormFields("branch").Result
  19.  
  20. Set appWord = CreateObject("Word.Application")
  21. appWord.Visible = True
  22.  
  23. Set doc = appWord.Documents.Add(Template:="S......Y.docm", NewTemplate:=False, DocumentType:=0)
  24.  
  25. doc.FormFields("name1").Result = Name
  26. doc.FormFields("ssn").Result = SSN
  27. doc.FormFields("bday").Result = bday
  28. doc.FormFields("address").Result = address
  29. doc.FormFields("dayphone").Result = dayphone
  30. doc.FormFields("branch").Result = branch
  31.  
  32. End Sub
Jun 23 '15 #1
1 1649
zmbd
5,501 Expert Mod 4TB
+ Please confirm, this is in MS Word... not MS Access?

+ Also which version of Office/Word are you using?

+ We need to know the design of the listboxes too... multi-column? on a popup or a document (see the following)?

+ Form, we need to understand your "definition" of form. In word, people use the term "form" to refer to both the "dialog style" form that pops up an you place information into and the "document style" form where one opens a *.doc, *.docx, *.docm word document and there resides a template with fields that the user places entries into.

The basic method will be to loop thru your current list box items and then use the additem method to refer to your form.
Jun 23 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: bh_jodokast | last post by:
It's pretty easy to do a drag from one listbox to another listbox when using Windows.Forms, but on the web, forms are handled differently. My plan is to use two listboxes and a DHTML HTC file to...
5
by: Dave | last post by:
Hi All, I have a windows form that contains 2 listboxes and 2 buttons. The listbox on the right is populated by a database routine (This is the easy part). The listbox on the left is populated...
1
by: anjupt | last post by:
Hi, I have 2 listboxes with data fetched from database so for both the listboxes datasource is set .i tried to move data from one listbox to another listbox but Error"An unhandled exception of...
3
by: perrycheung221 | last post by:
Hi guys, I got 2 listboxes in a window form, one on left and one on right. The 1st listbox have some items while the 2nd listbox is empty. Also there are 2 buttons between the 2 listboxes which...
1
by: dkohel | last post by:
I have 2 list boxes on my form. I am trying to populate listbox B with the selection from listbox A. I have set multi-select in both boxes to Extended... The user will select the items from...
1
by: SuriAug05 | last post by:
Hello, I have created one web page. In that i have used two listboxes. Now i want to drag an item from one listbox and drop the same item in another listbox. And also want to rearange the items...
5
by: sreenu123 | last post by:
Hi, I want to read from values from database and add to listbox then transfering items from one listbox to another listbox using C#.NET. Can any one give source code. Thanks in advance sree
5
by: Aaitaman Tamang | last post by:
Hi everybody, I have two listbox in my form, the name of listbox is “ListBox1” and another is “ListBox2”. The ListBox1 Row Source Type is (Table/Query) where users will see all the employee Badge...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.