ACC2002: Functions Cause Scripting Errors When Forms or Reports Are Exported as XML Documents (282374)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q282374
Novice: Requires knowledge of the user interface on single-user computers.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you export a Microsoft Access object (a form or a report) by using the XML Documents setting, and you include an HTML 4.0 presentation file, you may receive an error message similar to the following when you attempt to view the HTML document in your Web browser:
A Runtime Error has occurred.
Do you wish to Debug?

Line: 19
Error:
Microsoft VBScript runtime error
Type mismatch: 'CVar'
line = 1, col = 0 (line is offset from the <xsl:script> tag).
Error returned from property or method call.

CAUSE

This behavior can occur if you export an Access object that uses a Microsoft Visual Basic for Applications (VBA) function that is not supported by Visual Basic Scripting Edition (VBScript).

RESOLUTION

To work around this issue, either remove the function that is causing the problem or replace it with a similar function that is supported by VBScript. For a list of functions that are supported by VBScript, refer to the VBScript Language Reference available on the Visual Basic Scripting home page at the following Microsoft Web site: To determine which VBA function is causing the problem, examine the run-time error that you receive for clues. For example, in the error message described in the "Symptoms" section, the line that reads "Type mismatch: 'CVar'" indicates a problem with the CVar function, which is not supported by VBScript.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Problem

  1. Start Access and open a new blank database.
  2. In the Database window, under Objects, click Tables, and then click New.
  3. In the New Table dialog box, click Design View, and then click OK.
  4. Create a field called MyNumber with a data type of Number.
  5. On the File menu, click Save, name the table Table1, and then click OK. When you are asked if you want to define a primary key, click No.
  6. On the View menu, click Datasheet View. In the first record, type 1234, and then close the table.
  7. In the Database window, under Objects, click Forms, and then click New.
  8. In the New Form dialog box, click Design View. In the Choose the table or query where the object's data comes from drop-down list, select Table1, and then click OK.
  9. In the toolbox, click Text Box, and then insert a text box in the form.
  10. If the property sheet is not already visible, click Properties on the View menu.
  11. Click the Data tab in the property sheet. Set the Control Source property to =CVar([MyNumber]) & "A".
  12. On the File menu, click Save, name the form TestCVar, and then click OK.
  13. In the Database window, click Forms, right-click TestCVar, and then click Export.
  14. In the Export Form To dialog box, name the file CVarForm, and then in the Save as type box, select XML Documents. Click Export, and then click OK.
  15. In Microsoft Windows Explorer, navigate to the folder that contains the CVarForm HTML document, and then double-click CVarForm.htm to open it in your browser. Notice that you receive the error message described in the "Symptoms" section.

REFERENCES

For more information about using Access and Extensible Markup Language (XML), click Microsoft Access Help on the Help menu, type about xml data and access in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:11/6/2003
Keywords:kbbug kberrmsg kbpending KB282374