Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CreateReportControl Method

Posted on 1998-08-09
2
Medium Priority
?
804 Views
Last Modified: 2013-11-25
I am trying to create an Access Report from VB5.
I have successfully created the report, but I want to Set a Control Object variable, so I can use the controls properties.

I have the following code in a Button_Click event

    Dim appAccess As Access.Application
    Dim rpt As Report
    Dim ctlText As Control
    Dim ctlLabel As Control

    Set appAccess = New Access.Application
    appAccess.OpenCurrentDatabase db.Name
       
    Set rpt = appAccess.CreateReport(CurrentDb.Name)
' This next line produces a run time error #13 - type mismatch
    Set ctlText = rpt.Application.CreateReportControl _
    (rpt.Name, acTextBox, acDetail, "", "PointNumber", , , 1000, 260)
   
    Set ctlLabel = rpt.Application.CreateReportControl _
    (rpt.Name, acLabel, acPageHeader, ctlText.Name, "", , , 1000, 260)

It works fine if I just use,
rpt.Application.CreateReportControl _
    (rpt.Name, acTextBox, acDetail, "", "PointNumber", , , 1000, 260)
But when I try to set it = ctlText, the error #13 results.
From all of the examples I've read, this should work!!
The instance of Access and CreateReport works fine.
Thanks
0
Comment
Question by:electrick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
percosolator earned 450 total points
ID: 1468380
You are more than likely using examples written for Access.  I tried it in VB5, and got the type mismatch that you did.

Once I cut and pasted the code into Access, Voila!  C'est Magnifique!  (it worked)

What you are encountering is that MS-Access uses VBA (Visual Basic for Applications).  VBA and VB are not the same.

A VB text box is a different animal than an Access Report Textbox, hence, your type mismatch.  The "Control" datatype that was dimensioned is a generic VB datatype for VB controls.

Change your DIM statements to this:

    Dim ctlText As Access.TextBox
    Dim ctlLabel As Access.Label

I Did that in VB5 and it seemed to work (though you don't get any context menus).  The text box worked fine, but every time VB hit the "Set ctlLabel =" statement, VB gave me a GPF and Windows shut it down.

It might be my machine, or an inherent bug, I don't know.  If it works for you, let me know.




0
 

Author Comment

by:electrick
ID: 1468381
That did it!, and I got the same GPF you got.  I've narrowed it down to an "Unhandled Exception" in Module OLEAUT32.DLL.
The function is called VariantCopy(). Must be a flaw in the DLL.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question