Microsoft KB Archive/102479

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 09:21, 20 July 2020 by X010 (talk | contribs) (Text replacement - """ to """)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Article ID: 102479

Article Last Modified on 10/28/2003



APPLIES TO

  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 3.0 Professional Edition



This article was previously published under Q102479

SYMPTOMS

If you try to use the domain aggregate function examples provided in the Microsoft Visual Basic version 3.0 for Windows Help file, you will receive this error message:

Reference to undefined Function or array

CAUSE

The examples for the domain aggregate functions are incorrect. The domain aggregate functions, like the SQL aggregate functions, can be used only within an SQL statement.

WORKAROUND

Use the domain aggregate functions within an SQL statement, as in the following example. Enter the following as one, single line:

   Set Dn = Db.CreateDynaset("Select DAvg(""AU_ID"", ""AUTHORS"")
      FROM Authors")

STATUS

Microsoft has confirmed this to be a bug in the Visual Basic version 3.0 Help file. This problem has been corrected in Visual Basic version 4.0.

MORE INFORMATION

Step-by-Step Example

The following example demonstrates how to print to the form an average of all the AU_ID values in the Authors table from the BIBLIO.MDB database that comes with Microsoft Visual Basic version 3.0 for Windows:

  1. Start Visual Basic or from the File menu, choose New Project if Visual Basic is already running. Form1 is created by default.
  2. Add the following code to the Click event of Form1:

       Sub Form_Click()
          Dim Db As Database
          Dim Dn As Dynaset
    
          Set Db = OpenDatabase("C:\VB\BIBLIO.MDB")
          ' Note: enter the following Set Dn code as one, single line.
          Set Dn = Db.CreateDynaset("Select DAvg(""AU_ID"", ""AUTHORS"")
             FROM Authors")
             Print Dn(0) ' This is the equivelant of
                         ' Form1.Print Dn.Fields(0).Value
          ' It is always a good idea to close the database objects:
          Dn.Close
          Db.Close
    
       End Sub
  3. Run the example. Then click the form.

All the other domain aggregate functions work in a similar way. It is only the example that is incorrect in the Visual Basic Help file. The other information explaining how to use the function parameters is correct.

The Following are the Domain Aggregate Functions:

DAvg
DCount
DFirst
DLast
DLookup
DMin
DMax
DStDev
DStDevP
DSum
DVar
DVarP



Additional query words: buglist3.00 3.00 fixlist4.00

Keywords: kbbug kbfix KB102479