Microsoft KB Archive/169156: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - """ to """)
 
(One intermediate revision by the same user not shown)
Line 68: Line 68:
<pre class="codesample">  Sub IntervalTest()
<pre class="codesample">  Sub IntervalTest()
       Dim x as String
       Dim x as String
       If x <&gt; &quot;&quot; Then
       If x <> "" Then
         Debug.Print DateAdd(x,1,Date)
         Debug.Print DateAdd(x,1,Date)
       Else
       Else
         MsgBox &quot;The interval argument is invalid.&quot;
         MsgBox "The interval argument is invalid."
       End If
       End If
   End Sub
   End Sub
Line 80: Line 80:
<pre class="codesample">  Sub IntervalTest()
<pre class="codesample">  Sub IntervalTest()
       Dim x as String
       Dim x as String
       x = &quot;&quot;
       x = ""
       ' Add other code here that sets the value of x
       ' Add other code here that sets the value of x
       Debug.Print DateAdd(x,1,Date)
       Debug.Print DateAdd(x,1,Date)
Line 123: Line 123:
Note that you receive the error message.<br />
Note that you receive the error message.<br />
<br />
<br />
NOTE: You may receive an &quot;Out of Stack Space&quot; run-time error, instead of a page fault, the first time you run this procedure. However, subsequent execution of the procedure results in a page fault error.</li></ol>
NOTE: You may receive an "Out of Stack Space" run-time error, instead of a page fault, the first time you run this procedure. However, subsequent execution of the procedure results in a page fault error.</li></ol>




Line 131: Line 131:
== REFERENCES ==
== REFERENCES ==


For more information about DateAdd(), DatePart(), or DateDiff() functions, ask the Microsoft Access 7.0 Answer Wizard for &quot;date functions.&quot;
For more information about DateAdd(), DatePart(), or DateDiff() functions, ask the Microsoft Access 7.0 Answer Wizard for "date functions."


</div>
</div>

Latest revision as of 10:04, 21 July 2020

Article ID: 169156

Article Last Modified on 11/17/2000



APPLIES TO

  • Microsoft Access 95 Standard Edition



This article was previously published under Q169156

Moderate: Requires basic macro, coding, and interoperability skills.


SYMPTOMS

When you pass an uninitialized string variable to the interval argument of the DateAdd(), DatePart(), or DateDiff() functions in Microsoft Access 7.0, you receive the following error message:

MSACCESS caused an invalid page fault in module VBA232.DLL

RESOLUTION

Always pass a valid interval value to the DateAdd(), DatePart(), and DateDiff() functions. To be sure you pass a valid interval value, you can test for the value of the variable before you invoke the function, as in the following example:

   Sub IntervalTest()
      Dim x as String
      If x <> "" Then
         Debug.Print DateAdd(x,1,Date)
      Else
         MsgBox "The interval argument is invalid."
      End If
   End Sub
                


Another way to prevent the page fault error is to initialize the variable as a zero-length string as soon as you declare it. For example:

   Sub IntervalTest()
      Dim x as String
      x = ""
      ' Add other code here that sets the value of x
      Debug.Print DateAdd(x,1,Date)
   End Sub
                


Then, if you do not set the value of the variable to a valid interval before you pass it to the DateAdd(), DatePart(), or DateDiff() function, you receive the following error, but Microsoft Access does not terminate:

   Run-time error '5':
   Invalid procedure call
                

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access 7.0. This behavior does not occur in Microsoft Access 2.0 or 97.

MORE INFORMATION

Steps to Reproduce Problem

WARNING: Following these steps will cause a page fault on your computer. Make sure you save and close any open work on your computer before following these steps.

  1. Start Microsoft Access 7.0 and open the sample database Northwind.mdb.
  2. Create a module and type the following procedure:

          Sub Test()
             Dim x as String
             Debug.Print DateAdd(x,1,Date)
          End Sub
                            
  3. To test this procedure, type the following line in the Debug window, and then press ENTER.

    Test

    Note that you receive the error message.

    NOTE: You may receive an "Out of Stack Space" run-time error, instead of a page fault, the first time you run this procedure. However, subsequent execution of the procedure results in a page fault error.


REFERENCES

For more information about DateAdd(), DatePart(), or DateDiff() functions, ask the Microsoft Access 7.0 Answer Wizard for "date functions."


Additional query words: MSACCESS caused an invalid page fault in module VBA232 DLL

Keywords: kberrmsg kbbug kbprogramming KB169156