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!

Get value from Word form field to load into Access 2003

Status
Not open for further replies.

alexisb

Programmer
Apr 5, 2001
100
US
I wrote a VB program to load data from a Word file with many tables into Access. The Word tables are all form fields, some of which are drop-downs with several choices. The load is working except for one problem. I created buttons on the protected form to allow users to add or delete rows as there is no way for me to know exactly how many rows each user will need.

I can get the data no problem when I know the fieldname:
rst![cust] = doc.FormFields("cust").Result

However, how can I get the result of a drop-down in a row that has been added since I won't know the name of the field that's generated? Is there any way to say something like this:
rst![choice] = doc.FormFields(currentcell).Result?

I am using MoveLeft, MoveRight, etc. to get in the correct cell. Without using the formfield(fieldname).result logic, I get garbage data loaded in the field, rather than the selection made by the user.

I hope this makes sense. I have checked books and did a search on this site. Any help will be appreciated.
Thanks,
Alexis
 
I was able to add the bookmark in the Word file from Access but I am still not able to reference the field value from Access. I did some testing and determined that, although the bookmark is being set by Access, it is not actually a "real" bookmark. In Word, I can "GoTo" the bookmark I created from Access using Find, but the bookmark name is not actually in the field box next to bookmark, which would have happened if I had created the bookmark manually in Word. It seems to me that the bookmark is being created for the location but not for the actual field.

Has anyone worked with bookmarks before programmatically from Access into Word? This is the last piece of code I have to get working and then I am done this project. The problem originated because my Word doc allows users to add rows with a button (macro in Word). I checked Word doc and Word blanks out the bookmark during a copy for formfields. I tried writing VB code in Word in the addrow macro but it just didn't work due to the row copy functionality. As I explained in my earlier post, the problem with getting the value only happens for drop-downs. I have 4 drop-downs in my form.

Thanks for your help.
Alexis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top