ACC2: GPF Using GetChunk Method As Argument for Put Statement

ID: Q117611


The information in this article applies to:


SYMPTOMS

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

When you use the GetChunk method in the third parameter of a Put statement, you may receive a general protection (GP) fault.


CAUSE

The third parameter of the Put statement requires a variable name. You cannot directly use a method (such as the GetChunk method) as a statement argument.


RESOLUTION

Create an intermediate variable, assign the value returned from the GetChunk method to this variable, and then use the variable as the third parameter of the Put statement. This technique is demonstrated in the "Workaround" section later in this article.


STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.


MORE INFORMATION

Steps to Reproduce Problem

WARNING: Following these steps will cause a general protection fault on your computer. Make sure you save and close any open work on your computer before following these steps.
  1. Start Microsoft Access and open the sample database NWIND.MDB.


  2. Create a new module and enter the following function:
    
          Function Test ()
             Dim d As Database, rs As Recordset
    
             Set d = CurrentDb()
             Set rs = d.OpenRecordset("Employees", DB_OPEN_TABLE)
    
             Open rs![Last Name] & ".txt" For Binary As #1
             Put #1, , rs![Notes].GetChunk(0, 1000)
             Close #1
             rs.Close
             d.Close
          End Function 


  3. From the View menu, choose Immediate window.


  4. Type the following line in the Immediate window, and then press ENTER:

    ?Test()

    Note that you receive a GP fault.


Workaround

The following sample function is a modified version of the Test() function above. This version of the Test() function will generate a text file with a portion of the Notes memo field from the first record of the Employees table. The name of the text file is determined by the first eight characters of the Last Name field. Note that in this version, the Put statement uses the variable X for the third parameter, which is set equal to the GetChunk method.

   Function test ()
         Dim d As Database, rs As Recordset
         Dim x As String

         Set d = CurrentDb()
         Set rs = d.OpenRecordset("Employees", DB_OPEN_TABLE)

         Open rs![Last Name] & ".txt" For Binary As #1
         x = rs![Notes].GetChunk(0, 1000)
         Put #1, , x
         Close #1
         rs.Close
         d.Close

   End Function 


REFERENCES

For more information about the Put statement, search for "Put," and then "Put Statement" using the Microsoft Access Help menu.

Additional query words: gpf


Keywords          : kberrmsg IntpOle 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 6, 1999