You can use datasheet statements in scripts to navigate, read from and write to local or external datasheets, limit the data in a datasheet, and return values from datasheets.
Use datasheet statements if:
Note: You cannot use datasheet statements if the datasheet is associated with a script.
1. Add the statements to perform.
2. Before the statements you want to use datasheet values in, add a variable equal to the OpenRecordset statement and datasheet to access.
The OpenRecordset syntax is OpenRecordset("DatasheetName").
Note: If the datasheet uses a script-generated query to retrieve data during playback, add a variable equal to the OpenRecordsetQuery statement.
3. Add variables for each datasheet column used in the script. Set each variable equal to the GetRowValue statement.
The GetRowValue syntax is GetRowValue (Recordset, "ColumnName").
4. Select the statement you want to assign data to.
5. Choose Script > Edit Statement. The Edit Statement dialog box opens.
6. Select Expression.
7. Enter the variable that contains the datasheet column to use.
8. Click OK.
The datasheet reference is added to the statement.
In the following example, database statements open a recordset named AccessDatabase and retrieve values from the First_Name, Last_Name, Company, Phone_Number, and Email_Address datasheet columns. The SetRowValue statement writes the value of the lastName variable plus '@wysicorp.com' to the Email_Address column in the current datasheet row. The datasheet values are entered in the form, the form is submitted, and the script navigates back to the form page.
The Do...Loop Until statement instructs the script to continue entering the corresponding datasheet values in the form until the last datasheet row is used. When the last row is used, the browser window closes.
Recordset = OpenRecordset("AccessDatabase")
DofirstName = (GetRowValue(Recordset,"First_Name"))
lastName = (GetRowValue(Recordset,"Last_Name"))
company = (GetRowValue(Recordset,"Company"))
phoneNumber = (GetRowValue(Recordset,"Phone_Number"))
SetRowValue(Recordset,"Email_Address",lastName +"@wysicorp.com")
emailAddress = (GetRowValue(Recordset,"Email_Address"))
Window("WysiCorp Report a Bug").Editbox("First Name").TypeText(firstName)
Window("WysiCorp Report a Bug").Editbox("Last Name").TypeText(lastName)
Window("WysiCorp Report a Bug").Editbox("Email Address").TypeText(emailAddress)
Window("WysiCorp Report a Bug").Editbox("Company").TypeText(company)
Window("WysiCorp Report a Bug").Editbox("Phone Number").TypeText(phoneNumber)
Window("WysiCorp Report a Bug").Button("Send to WysiCorp").Click()
Window("Browser").Navigate("http://www.wysicorp.com/wysicorp/reportbug.html")
NextRow(Recordset)
Loop Until RecordsetEOF(Recordset)
Window("Browser").Close()
Note: Additional examples are available in the DatabaseOperations and DatabaseCheckpoints sample workspaces.