View Single Post
  #4  
Old October 13th 08, 01:40 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Using Object Data in VBScript

Where do the object variables "Subject" and "Student" come from? Your code
snippet doesn't that.

As explained in the article I suggested, the value of the Subject property
of any Outlook item, is usually returned and set in form code with
Item.Subject. Therefore, your could should be something more like:

Item.Subject = Item.Subject & some new value

Where some new value comes from depends on the information that's missing
from your code snippet -- how the Student object variable is derived. Going
solely on the error message, it looks like Student is not an object variable
at all, but instead is a string variable, in which case, the statement to
update the subject would be:

Item.Subject = Item.Subject & Student
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54

"Gary Newport" wrote:

I have used the property values set in design wherever possible but I need
things to change as the form is completed/sent.

I have now realised that I am using the textbox name, rather than the bound
name so have changed the one code to...

Function Item_Send()

dim mySubject
dim myStudent

Set mySubject = Subject
Set myStudent = Student
mySubject.Value = mySubject.Value & myStudent.Value

End Function

However, when I run this form I get the error:

Microsoft VBScript runtime error: Object required: '[string: "Round Robin
for "]'

Now the text given is contained within the bound field of Subject and this
appears as the stored property when I undertake a watch. So the object is
being recognised by the editor but not being transferred to the new set
variable mySubject.

Equally, Student is not receiving it's value, even though it has been
entered into the field.

I need this to update the Subject field just before being sent.

"Sue Mosher [MVP-Outlook]" wrote:

Control values are generally the wrong approach. Instead, use the property
values, e.g. Item.Subject. See http://www.outlookcode.com/article.aspx?ID=38

"Gary Newport" wrote:

I have asked this elsewhere but thought it would be better as an identifiable
question...

How can I use the value of a textbox elsewhere (such as the subject textbox)
when sending the message?

Also, can I do the same to enable/disable a control?

Function Item_Send()

dim mySubject
dim myTextbox1

Set mySubject = txtSubject
Set myTextbox1 = txtTextbox1
mySubject.Value = "Round Robin for " & myTextbox1.Value

End Function

Ads