Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Get value from Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nigel - 05 Oct 2006 16:03 GMT
I am trying to get a value from a field on a form but no matter what I do the
value returned is always 70, here is the code I am using

Sub SR()

Dim Message, Title, vusername
Message = "Is this Member Competing in Stationary Roping (Y or N)"    ' Set
prompt.
Title = "Stationary Roping"    ' Set title.
  ' Set default.
' Display message, title, and default value.
vSR = InputBox(Message, Title)
     ActiveDocument.FormFields("Sr").Result = vSR
MsgBox ActiveDocument.FormFields("Level")
Exit Sub
End Sub

The message box is just a msg validating what value I am getting because I
am going to do some other stuff after that, where am I going wrong in getting
the value from a field

thanks
Dave Lett - 05 Oct 2006 16:24 GMT
Hi Nigel,

This might be too simple, but you're setting the value of the "Sr" field but
showing the value of the "Level" field. Perhaps you should change the line:

MsgBox ActiveDocument.FormFields("Level")

to

MsgBox ActiveDocument.FormFields("Sr")

HTH,
Dave

>I am trying to get a value from a field on a form but no matter what I do
>the
[quoted text clipped - 21 lines]
>
> thanks
Nigel - 05 Oct 2006 16:43 GMT
Its actually looking back to another field on the form and what I want to do
is check the value in the level field and if it is greater than 4 go to one
field and if its less than 4 go to another field, I can do all that easy
enough but I  just can't get the value from the level field

> Hi Nigel,
>
[quoted text clipped - 35 lines]
> >
> > thanks
Dave Lett - 05 Oct 2006 17:10 GMT
Hi Nigel,

The default value of the Level field is probably "70." However, the current
result of the Level field might be something else entirely. To get the
current result, use

MsgBox ActiveDocument.FormFields("Level").Result

HTH,
Dave

> Its actually looking back to another field on the form and what I want to
> do
[quoted text clipped - 46 lines]
>> >
>> > thanks
Tony Jollans - 05 Oct 2006 18:47 GMT
Actually the 70 is the value of the default property of the FormField. When
you reference the FormField with other than a Set statement you are asking
for the default property, which in this case is Type - wdFieldFormtextInput
(value 70). If you want the value as seen on screen (the Result) you should
explicitly say so, as per Dave's suggestion.

--
Enjoy,
Tony

> Hi Nigel,
>
[quoted text clipped - 57 lines]
> >> >
> >> > thanks
Dave Lett - 05 Oct 2006 17:11 GMT
Hi Nigel,

You can test this with the following:

ActiveDocument.FormFields("Level").Result = 44

MsgBox ActiveDocument.FormFields("Level")
MsgBox ActiveDocument.FormFields("Level").Result

HTH,
Dave

> Its actually looking back to another field on the form and what I want to
> do
[quoted text clipped - 46 lines]
>> >
>> > thanks
Nigel - 05 Oct 2006 18:31 GMT
Thanks Dave that worked,

Can I ask another question

I have some calculations ont he form and I want to nadd the totals together
so I am using the follwoing

ActiveDocument.FormFields("ATOTAL").Result =
ActiveDocument.FormFields("A1Ext").Result +
(ActiveDocument.FormFields("A2Ext").Result) +
(ActiveDocument.FormFields("A3Ext").Result) +
(ActiveDocument.FormFields("A4Ext").Result) +
(ActiveDocument.FormFields("A6Ext").Result)

if I use a msg box on each of those fields I will get the values  in the
field ie 35.00 20.00 etc

but when I use the above statment it it treating the + as concat and joins
them together, the fields on the form are numbers, is ther an easy way to add
2 or more fields together

Thanks

> Hi Nigel,
>
[quoted text clipped - 58 lines]
> >> >
> >> > thanks
Dave Lett - 05 Oct 2006 19:13 GMT
Hi Nigel,

You can try specifying a data type:

CLong (ActiveDocument.FormFields("A1Ext").Result)

HTH,
Dave

> Thanks Dave that worked,
>
[quoted text clipped - 89 lines]
>> >> >
>> >> > thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.