Microsoft KB Archive/104711

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

ACC1x: Creating Unbound Object Frame with CreateControl()

Q104711



The information in this article applies to:


  • Microsoft Access versions 1.0, 1.1





SYMPTOMS

When you use the CreateControl() function with a controltype argument of 114 to create an unbound object frame, Microsoft Access causes a general protection (GP) fault when you view the form in Form view.



CAUSE

The CreateControl() function does not provide any method for specifying the object to embed in the new control. Instead, an empty, unbound object frame is created. Note that you cannot create an empty, unbound object frame when you create the frame manually because Microsoft Access displays an Insert Object dialog box in which you must select the object to embed.



RESOLUTION

The GP fault occurs because Microsoft Access does not expect to run with an empty, unbound object frame. The CreateControl() function does not provide any method of specifying the object to embed.

The following example demonstrates how to use the sample function CreateUnboundObjectFrame() to create an unbound object frame using a DoMenuItem action:

NOTE: In the following sample code, an underscore (_) is used as a line- continuation character. Remove the underscore when re-creating this code in Access Basic.


  1. Create a new module, and enter the following:

          Function CreateUnboundObjectFrame (ByVal sFormName$, _
                                             ByVal sObjectPath$)
    
             A_FORMDESIGNBAR = 3
             A_INSERTOBJECT = 10
    
             DoCmd SelectObject A_FORM, sFormName
             SendKeys "%f" & sObjectPath & "{ENTER}"
             DoCmd DoMenuItem A_FORMDESIGNBAR, A_EDIT, A_INSERTOBJECT
    
          End Function 
  2. Create a new, unbound form. Save the form as Chess.
  3. With the form open, select the Database window.
  4. Create a new module.
  5. In the module's Immediate window, type the following, and then press ENTER:

    ? CreateUnboundOjbectFrame("Chess", "c:\windows\chess.bmp")

NOTE: This example assumes that the CHESS.BMP file supplied with Microsoft Windows is located in the C:\WINDOWS directory.



STATUS

Microsoft has confirmed this to be a problem in Microsoft Access versions 1.0 and 1.1. This problem no longer occurs in Microsoft Access version 2.0.



MORE INFORMATION

Steps to Reproduce Problem



  1. Create a new, unbound form. Save the form as CreateControlTest.
  2. With the form open, select the Database window.
  3. Create a new module. Enter the following sample function:

          Function CreateUnboundObjectFrame ()
             Dim C As Control
             Set C = CreateControl("CreateControlTest", 114)
          End Function 
  4. In the module's Immediate window, type the following, and then press ENTER:

    ? CreateUnboundObjectFrame()
  5. View the CreateControlTest form in Form view. The following error message will occur:

    An error has occurred in your application. If you choose Ignore, you should save your work in a new file. If you choose Close, your application will terminate.

If you choose Close or Ignore several times, the following error message will occur:


MSACCESS caused a General Protection Fault in module MSACCESS.EXE at 0096:50B6.



REFERENCES

Microsoft Access "The Secrets of AccessWizards," pages 12-14

Microsoft Access "Language Reference," pages 151-152 and 433-434

Additional query words: ADK GPF

Keywords : kberrmsg kbprg
Issue type : kbbug
Technology :


Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.