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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access getting data from drop-down formfields in Word

Status
Not open for further replies.

alexisb

Programmer
Apr 5, 2001
100
US
Please see the thread below for details, originally posted in the Access VBA coding forum but with no response.
thread705-951390

I created a Word form with multiple tables that I want to load into Access. The cells of the tables are all formfields. I have no problem reading the data from text box formfields, but the problem is with the drop-down formfields. My Word form allows the users to copy rows since it is not known exactly how many rows will be needed each time the form is used. That's where the problem is. When Word adds the row (my macro), the booksmarks are removed. If the bookmarks are removed, Access can’t “see” the data from the drop-down formfields. I have tested this fully and if I plug in bookmarks for all those drop-down formfields, the load works fine.

Thus, I know my problem is I need to find a way to “see” that data in the drop-down formfields. I was able to programmatically create the bookmarks in the word doc and I thought I was home free. But, for some reason, although I can confirm the bookmarks are there, the bookmark property with .result says it is not available in the collection. I am baffled. I do notice that when I programmatically add the bookmarks, when I look in the Word file, you can’t actually see the bookmark when you double-click in the field. I tried recording a macro in Word to see the actually code lines but the recorder won’t work for inserting a bookmark.

Here’s a sample of my code in Access where the problem lies.

If (lngRows - 2) = 1 Then doc.Bookmarks.Add NAME:="prob1", Range:=Selection.Range
If doc.Bookmarks.Exists("prob1") = True Then
MsgBox " true - line#: " & (lngRows - 2)
!problem = doc.FormFields("prob1").Result
End If

The first IF statement successfully adds the bookmark to the WORD doc. The second IF confirms the bookmark was added to the form field, but the line with !problem bombs with the message “Error 5941: Requested member of the collection does not exist”. I don’t understand that because in lines above this one where the field was not a drop-down (but still a formfield), I used this line to get the data in the drop-down (see next line):

![visit_summary1] = doc.FormFields("visitsumm1").Result

Any help would be appreciated. I have checked book after book, many sites and tek-tips and not much has been answered on Word automation regarding bookmarks on drop-down formfields.

Thanks,
Alexis
 
word copy row with dropdown formfield? works, but original dropdown looses bookmark name (and bookmark).

bookmark do not have .Result. Formfield jave .Result

formfield ALSO r bookmark

if use activex dropdown, problem not present.

put activex control dropdown at location u want.
select it, make bookmark of it.
in code to make copy row - not clear how u doing this, or if dropdown in 1st cell row.
if is, use GoTo to select bookmarked activex, collapse to start.
make range object for entire row, copy range
collapse range
move selection to last cell, and last point/characterin cell.
paste range
activex control copied has same name, and bookmark moved with it
new (copied) control has name of original with "1" added.

do again and new activex control is named original2 then original2, etc.

rgis make easy to get value out.
 
Thanks, Phaed. I think I see where you are going. I didn't realize about the ActiveX controls in Word as I've haven't done any VB programming in Word in the past. I will rework my code. I'll let you know how it goes.
Thanks again.
Alexis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top