Microsoft Office Tutorials and References
In Depth Information
FIGURE 27.16
The Script Editor.
Many of the syntax elements of VBScript are identical to those in VBA (refer to Chapter 23). A
detailed treatment of VBScript is beyond the scope of this topic, but I will present an example to
give you a feel of how it is used.
Suppose you have designed a custom form with a page that contains several TextBox controls for
the user to enter data. You want to provide an easy way for the user to clear all the TextBox
controls and start over. VBScript is perfect for this.
First, add a CommandButton to the form and use its property sheet to change its caption to
Clear . Then, open the Script Editor and enter the code shown here. This assumes that the page
the controls are on is named PageName and that the TextBox controls you want to clear are named
TextBox1, TextBox2, and TextBox3:
Sub CommandButton1_Click()
Set MyPage = Item.GetInspector.ModifiedFormPages(“PageName”)
MyPage.Controls(“TextBox1”).Value = “”
MyPage.Controls(“TextBox2”).Value = “”
MyPage.Controls(“TextBox3”).Value = “”
End Sub
The first line of code gets a reference to the form page that you want to work with. The other lines
each get a reference to a TextBox and set its Value property to a blank string.
Search JabSto ::

Custom Search